<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: One Code for two Autocad Version in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9673912#M18792</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...If you really want to only have a single version of your app, you can use &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;late binding&lt;/STRONG&gt;&lt;/FONT&gt;: your first develop your code with earlier version of SheetSet COM API type library referenced. &lt;EM&gt;Once the code is debugged, you remove the reference, fix all the explicitly declared types in SheetSet model into "&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dynamic" (&lt;/STRONG&gt;&lt;/FONT&gt;assuming you are using C#), until the code can pass the building. There may be some tricky things to do, but it would the way to work with multiple version of COM APIs.&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you Norman&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;That is something i'm interested to learn.&amp;nbsp;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;Is there a web page i can look into so i understand this better?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2020 09:08:34 GMT</pubDate>
    <dc:creator>pbejse</dc:creator>
    <dc:date>2020-08-05T09:08:34Z</dc:date>
    <item>
      <title>One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672369#M18788</link>
      <description>&lt;P&gt;On a sheet set program, We normally create separate plug-ins for each version Autocad, all because sheet set&amp;nbsp; has its own specific NET library files (ACSMCOMPONENTS&lt;STRONG&gt;##&lt;/STRONG&gt;Lib) and also NET framework version.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way we can make just one plugin for two versions that share the same NET framework? say for example&lt;/P&gt;
&lt;P&gt;Autocad 2017 and 2018, only thing is, its using different library&amp;nbsp;files ( 21 and 22 respectively)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding both doesnt work.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":weary_face:"&gt;😩&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;..
using Autodesk.AutoCAD.Runtime;
&lt;FONT color="#0000FF"&gt;// 2017 
using ACSMCOMPONENTS21Lib;&lt;/FONT&gt;
&lt;FONT color="#FF0000"&gt;// 2018
using ACSMCOMPONENTS22Lib;&lt;/FONT&gt;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
AutoCAD.ApplicationServices.Application;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:25:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672369#M18788</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-08-04T15:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672475#M18789</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While you need to reference different library versions, you need to build one assembly per library version (i.e., have one project per version).&lt;/P&gt;
&lt;P&gt;But you can have all these projects in the same Visual Studio solution and only one project with the source code, in the other projects, you simply 'Add as link' the source code files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, did you first try to run the assembly (DLL) build against 2017 libraries in AutoCAD 2018 (or later)? Most of the times, it works because AutoCAD does not uses the referenced libraries which Copy Local property is false. it uses the libraries in the Global Assembly Cach (GAC) corresponding to the version. Referenced librries are only used by Visual Studio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 16:19:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672475#M18789</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2020-08-04T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672541#M18790</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;While you need to reference different library versions, you need to build one assembly per library version (i.e., have one project per version).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;I see, that confirms what i already been told.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But you can have all these projects in the same Visual Studio solution and only one project with the source code, in the other projects, you simply 'Add as link' the source code files.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you Gile, that is how i had it now.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.. But, did you first try to run the assembly (DLL) build against 2017 libraries in AutoCAD 2018 (or later)? Most of the times, ..&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Yes, I did try that after reading your post&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/net/make-one-dll-run-in-all-autocad-versions/m-p/4873292#M39533" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your quick response&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 16:43:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672541#M18790</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-08-04T16:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672562#M18791</link>
      <description>&lt;P&gt;If your code only deals with pure .NET APIs, then, as&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;suggested, you can try to reference the older version of .NET assemblies to build your code, and the chances are your app would most likely also work with later versions of AutoCADs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, since your question is specific about using SheetSet API, which is COM API (you set references to the COM type library and VS generates COM Interop .NET assembly as reference), then, no, you do need to build separate DLL as your Acad add-in for different MAJOR versions of AutoCAD, because each MAJOR version of AutoCAD registers the same classes in SheetSet models with different ClassId in Window Registry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really want to only have a single version of your app, you can use late binding: your first develop your code with earlier version of SheetSet COM API type library referenced. Once the code is debugged, you remove the reference, fix all the explicitly declared types in SheetSet model into "dynamic" (assuming you are using C#), until the code can pass the building. There may be some tricky things to do, but it would the way to work with multiple version of COM APIs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 16:53:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9672562#M18791</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-08-04T16:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9673912#M18792</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...If you really want to only have a single version of your app, you can use &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;late binding&lt;/STRONG&gt;&lt;/FONT&gt;: your first develop your code with earlier version of SheetSet COM API type library referenced. &lt;EM&gt;Once the code is debugged, you remove the reference, fix all the explicitly declared types in SheetSet model into "&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dynamic" (&lt;/STRONG&gt;&lt;/FONT&gt;assuming you are using C#), until the code can pass the building. There may be some tricky things to do, but it would the way to work with multiple version of COM APIs.&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you Norman&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;That is something i'm interested to learn.&amp;nbsp;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;Is there a web page i can look into so i understand this better?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 09:08:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9673912#M18792</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-08-05T09:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674457#M18793</link>
      <description>&lt;P&gt;Wrong account.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 13:49:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674457#M18793</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-05T13:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674489#M18794</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The C# dynamic type is mainly a simple way to use 'late binding', in other words, the type of objects is determined at execution time (the same as with LISP). You can see &lt;A href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/using-type-dynamic" target="_blank" rel="noopener"&gt;this topic&lt;/A&gt;. The inconvenient when using the dynamic type is that you loose the Visual Studio helpers related to strong types as intellisense and errors on compilation/edition time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following simple example illustrates the method &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt; described to replace strongly typed COM by dynamic type to be able to remove COM references.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You first build and debug your project using COM references and strong types in your code.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="COM_Reference_1.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/803614i6C24EB25A693128A/image-size/large?v=v2&amp;amp;px=999" role="button" title="COM_Reference_1.png" alt="COM_Reference_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then you simply comment the using instruction(s) related to AutoCAD.Interop so that Visual Studio find and displays all type errors&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="COM_Reference_2.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/803620i3E8C86D73C0DD3F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="COM_Reference_2.png" alt="COM_Reference_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can now replace the COM types by the 'dynamic' keyword and remove casts to COM types&lt;/P&gt;
&lt;P&gt;Note, if the code uses COM enumerations, you should also have to replace the enum memeber by the corresponding integer (eg acActiveViewport = 0, acAllViewports = 1).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="COM_Reference_3.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/803623i22AFEC16D58C00C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="COM_Reference_3.png" alt="COM_Reference_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You could also have use the 'var' keyword to let Visual Studio infer the type of objects which are properties of a dynamic one.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="COM_Reference_4.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/803625i6A1D6B44129A7645/image-size/large?v=v2&amp;amp;px=999" role="button" title="COM_Reference_4.png" alt="COM_Reference_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This done, if the code still work as expected, you can definitively remove the references to the COM libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use the &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-F2A96EC2-B693-498E-8425-258A0CE3653F" target="_blank" rel="noopener"&gt;Dynamic Language Runtime (DLR)&lt;/A&gt; to write code the same way as we do with 'dynamic languages' such as AutoLISP.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 13:53:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674489#M18794</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2020-08-05T13:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: One Code for two Autocad Version</title>
      <link>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674792#M18795</link>
      <description>&lt;P&gt;Another option I've used for handling this type of situation, is to fork a branch in the source control.&amp;nbsp; Common changes can be propagated to relevant branches while maintaining required uniqueness.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 15:36:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/one-code-for-two-autocad-version/m-p/9674792#M18795</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2020-08-05T15:36:47Z</dc:date>
    </item>
  </channel>
</rss>

