Launching multiple versions of AutoCAD from C# using "Activator.CreateInstance"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We have a .NET tool that uses AutoCAD to automatically process graphics. This tool uses a method identical to this article from Kean Walmsley’s blog: http://through-the-interface.typepad.com/through_the_interface/2009/05/interfacing-an-external-com-a...
I have been asked to make this tool work with a variety of different AutoCAD versions from AutoCAD 2010 to 2015, both 32 and 64 bit variants.
The ProgID's of the AutoCAD versions I need to CreateInstance for are:
"AutoCAD.Application.18" "AutoCAD.Application.18.1" "AutoCAD.Application.18.2"
"AutoCAD.Application.19" "AutoCAD.Application.19.1"
"AutoCAD.Application.20"
I am experiencing two problems:
First there are different versions of the Autodesk.AutoCAD.Interop.dll in ObjectARX SDK, corresponding to the different versions of AutoCAD. I cannot include references to all the different versions in the same Visual Studio project. Most importantly the interface ID’s for the IAcadApplication interface is different in all of them.
ObjectARX 2010 32-bit: 84F323FC-C179-4704-87E7-E3D576C2599E
64-bit: 2959C1CC-8577-4EDB-ADDC-6EBBAB147926
ObjectARX 2013 32-bit: 7558007D-8677-4FF1-BD48-B66281BD3DD7
64-bit: 070AA05D-DFC1-4E64-8379-432269B48B07
ObjectARX 2015 32-bit: 9FD28580-7461-4A57-AF4F-695AF5FDDA35
64-bit: 1C9CCE52-F48B-42CC-877B-F74905EC7DBC
Is there some method using Reflection that might enable me to create an instance of AutoCAD, and then reflect on the AutoCAD object to obtain the IAcadApplication interface at runtime?
The second problem I’m having is that when multiple versions of AutoCAD are installed side-by-side there is some confusion with the CreateInstance call. For Example, if AutoCAD 2013 and AutoCAD 2014 are both installed and I try to create an AutoCAD.Application.19 instance, I always get an AutoCAD.Application.19.1 instance. Is there a way I can prevent this, getting the AutoCAD.Application.19 instance I asked for.
Any information or strategy would be most helpful.
Thanks,
Eric Matthews