Author Topic: Multiple CAD version DLL  (Read 502 times)

0 Members and 1 Guest are viewing this topic.

pBe

  • Bull Frog
  • Posts: 366
Multiple CAD version DLL
« 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?

kpblc

  • Bull Frog
  • Posts: 247
Re: Multiple CAD version DLL
« Reply #1 on: February 08, 2017, 01:55:01 am »
I think you have to create some different projects and compile it to different locations.
Sorry for my English.

gile

  • Water Moccasin
  • Posts: 2047
  • Marseille, France
Re: Multiple CAD version DLL
« Reply #2 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).
« Last Edit: February 08, 2017, 03:40:04 am by gile »
Speaking English as a French Frog

nullptr

  • BricsCAD
  • Needs a day job
  • Posts: 6718
  • AKA Daniel
Re: Multiple CAD version DLL
« Reply #3 on: February 08, 2017, 04:07:01 am »
Alternatively, you might be able to use late binding.  probably more difficult though  :|

pBe

  • Bull Frog
  • Posts: 366
Re: Multiple CAD version DLL
« Reply #4 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

Jeff H

  • Needs a day job
  • Posts: 5759
Re: Multiple CAD version DLL
« Reply #5 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


pBe

  • Bull Frog
  • Posts: 366
Re: Multiple CAD version DLL
« Reply #6 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.

CADbloke

  • Bull Frog
  • Posts: 273
  • Crash Test Dummy
Re: Multiple CAD version DLL
« Reply #7 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.