TheSwamp

Code Red => .NET => Topic started by: pBe on February 07, 2017, 12:23:49 PM

Title: Multiple CAD version DLL
Post by: pBe on February 07, 2017, 12:23:49 PM
Hi Swampers

How do you deal with a single dll file to work on mutliple versions of Autocad, been working on a .net C# codes that deals with Sheet Set, among the required reference is the the file Interop.ACSMCOMPONENTS##Lib.dll

Code - C#: [Select]
  1.  using ACSMCOMPONENTS19Lib;  //Autocad 14
  2.  using ACSMCOMPONENTS20Lib;  //Autocad 15
  3.  using ACSMCOMPONENTS21Lib;  //Autocad 17

Not even sure i can load multiple reference of those shown above, tried it , it wont accept it though.

I figured to use Application.Version and pass the result to a switch statement.

Code - C#: [Select]
  1. string acadver = Autodesk.AutoCAD.ApplicationServices.Core.Application.Version.ToString();

After that i'm stump.

Any ideas?
Title: Re: Multiple CAD version DLL
Post by: kpblc on February 08, 2017, 01:55:01 AM
I think you have to create some different projects and compile it to different locations.
Title: Re: Multiple CAD version DLL
Post by: gile on February 08, 2017, 03:24:38 AM
Hi,

I think you have to build three different DLLs (i.e. 3 different projects in Visual Studio).
Anyway, these projects can be in the same Visual Studio solution and share the same code.

Create a first project (SheetSetProject_19 for example) referencing ACSMCOMPONENTS19Lib.
Add a conditional compilation symbol in the project properties > Build tab (ACAD_19 for example)
Write the code for this project with conditional compilation directives in the using directives:
Code - C#: [Select]
  1. #if ACAD_19
  2. using ACSMCOMPONENTS19Lib;
  3. #elif ACAD_20
  4. using ACSMCOMPONENTS20Lib;
  5. #elif ACAD_21
  6. using ACSMCOMPONENTS21Lib;
  7. #endif

Add a new project to the solution (SheetSetProject_20) referencing ACSMCOMPONENTS20Lib with a conditional compilation symbole (ACAD_20)
From the Project menu > Add Existing Item > browse to the Project_19 folder > select the code files to share > from the Add button drop-down list, select Add As Link.

Idem for SheetSetProject_21.

You can also set the same Output Path for the 3 projects in Release mode (in the Build tab of the projects properties).
Title: Re: Multiple CAD version DLL
Post by: It's Alive! on February 08, 2017, 04:07:01 AM
Alternatively, you might be able to use late binding.  probably more difficult though  :|
Title: Re: Multiple CAD version DLL
Post by: pBe on February 08, 2017, 10:47:10 AM

I think you have to build three different DLLs (i.e. 3 different projects in Visual Studio).
Anyway, these projects can be in the same Visual Studio solution and share the same code.

Create a first project (SheetSetProject_19 for example) referencing ACSMCOMPONENTS19Lib.....

I will try this, I'll let you guys know how it goes,
thank you gile

I think you have to create some different projects and compile it to different locations.

Thanks buddy

Alternatively, you might be able to use late binding.  probably more difficult though  :|

Too complicated for me, (dont even know what it is :) ) someday maybe, thanks
Title: Re: Multiple CAD version DLL
Post by: Jeff H on February 08, 2017, 11:46:23 AM
You can now create shared projects what if I remember correctly basically the same thing as gile's example.
Here is an example can download.
https://github.com/Hpadgroup/AcExtensionLibrary (https://github.com/Hpadgroup/AcExtensionLibrary)

Title: Re: Multiple CAD version DLL
Post by: pBe on February 08, 2017, 12:13:32 PM
You can now create shared projects what if I remember correctly basically the same thing as gile's example.
Here is an example can download...

downloading....

Thank you  Jeff H.
Title: Re: Multiple CAD version DLL
Post by: CADbloke on February 11, 2017, 03:22:56 AM
see also https://www.theswamp.org/index.php?topic=50202.0 for another approach I often use to share code between projects.