I recently installed AutoCAD 2011 for testing purposes, and compiled my .dll (with Visual Studio 2005) with 2011 set as the debug external program. However, now my compiled .dll doesn't work with AutoCAD 2010 and I can't seem to set my Type Library and Autodesk.AutoCAD.Interop.Common references back to 2010 versions, since it looks like they were overwritten in the C:\Program Files\Common Files\Autodesk Shared folder. The error message that pops up on 2010 computers is as follows:
Could not load file or assembly 'Autodesk.AutoCAD.Interop, Version=184.108.40.206, Culture=neutral, PublicKeyToken=...' or one of its dependencies. The system cannot find the file specified.
Is there a way to go back and create dll's for 2010 without uninstalling 2011 or using System Restore?
Since Acad2006 (maybe Acad2005, which I never installed), the Acad COM primary interop assembly is installed in GAC, where different version of the same assembly can be side-by-side.
For example, in my current computer, in the GAC, I have Autodesk.AutoCAD.Interop assemblies of 16.2.xxx (2006), 17.0.xxx(2007), 17.1.xxx(2008) and 17.2(2009).
So, when you set reference to this interop assembly, you should choose the versioon corresponding to your targeting Acad version. If you want your app work with multiple version of Acad, you'd better choose the oldest version of Interop assembly.
Acad's COM API is pretty good at backward compatibility. For example, my CAD addin apps uses Acad.Interop developed with Acad2006 (referenced to 16.2.xxx), but the apps work as expected with acad2007/8/9, recomplied or not.
Thanks, Norman. Maybe I'm just an idiot (distinct possibility), but I'm having difficulty with this. When I click on the Add button to add a reference and go to the COM tab, the only option I have for adding Interop is AutoCAD/ObjectDBX 180.0 Type Library, located in C:\Program Files\Common Files\Autodesk Shared\axdb18enu.tlb. Adding that, it indicates that the path is C:\Windows\assembly\GAC_MSIL\Autodesk.AutoCAD.Interop.Common\220.127.116.11__eed84259d7cbf30b\Autodesk.AutoCAD.Interop.Common.dll. If I go to the Browse tab instead of COM when adding, and go to C:\Windows\Assembly I can see I also have a 18.0.0 path available, but I can't select that from that tab.
I had a similar issue when I began upgrading my projects from 2009 to 2010, and the solution for my issue was to go to the Project Properties-> Refereneces Tab, select the autocad references you are using, and show the properties window. There is a property there called Specific Version, set it to true.
What I noticed after installing 2011 version (in my case Civil 3D 2011) the tlb type libraries which traditionally appeared on the list with different version numbers in the past did not show up. I had to search and load them from the files. Also, some methods are not available although the 2011 COM api documentation lists them as available 2011 COM methods. I am still struggling to see what is going and any reply from Autodesk would be very much appreiciated.
That's what I'm seeing, also. Under COM, I've got AutoCAD 2011 Type Library, but no AutoCAD 2010 Type Library, even though I didn't remove 2010 from my system and it's still functional. The dll I create works on my system on both 2010 and 2011 because the 2011 version of Autodesk.AutoCAD.Interop.dll is present and registered, but won't work on systems that don't have 2011 installed.
I'm afraid I might have to uninstall 2011 just so I can modify the dll for 2010 for my users.
Yes, when you install latest release of the same version of Acad (in your case, Acad 2010, and then Acad 2011, both are Version 18), even previous release' PIA is still in the GAC, but the Windows registry, which makes assembly in GAC shown in VS' "References" dialog box, is updated to only show latest release of the same Acad Version.
The easiest way to solve this is to download Acad ObjectARX SDK, The SDK has a "Inc" (and/or "Inc-win32", inc-x64") folder, in which all the reference DLLs are there for you, in cluding the COM Interop ones (Autodesk.AutoCAD.Interop.dll and Autodesk.AutoCAD.Interop.Common.dll).
You can browse to this folder from Reference dialog box and set reference to the interop dll. When your app runs, .NET always try to load the Interop assembly from GAC first.
Therefore, even your computer has 2010 and 2011 installed, you can still set interop reference to 2010 in the SDK folder, thus, your users who only has Acad 2010 can use your app without issue.
Thanks for all your help, Norman. I downloaded the SDK for 2010 and added the acax18enu.tlb and axdb18enu.tlb , but they still point to the AutoCAD 2011 dll's. I'm giving up for now and uninstalling 2011 so I can get back to work.
I do not understand why it is still pointing to Acad2011, if you set reference to the Acad.Interop.dll in Acad2010 SDK.
I did a quick test:
1. Start a new VS2008 class library project;
2, Open "add refernce..." dialog box;
3. use "Browse" tab to navigate to targeting ObjectARX SDK saved in the HD (See pic 1);
4. Set reference to AutoCAD.Interop.dll in Acad2010 SDK. the property window show correct version of the assembly is references (18.104.22.168); See pic.2.
5. Remove reference to AutoCAD.Interop.dll from 2010. do the same to AutoCAD.Interop.dll from Acad2011. The property window show the refernced assembly is version 22.214.171.124 (Acad2011).
See the picture attached.
Are you sure you downloaded in Acad2010, not Acad2011? When I went to Autodesk's ObjectARX SDK download site for Acad2011, it offers 3 versions of download (Acad2011/2010/2009). But my Acad 2010 SDK was downloaded last year.
Hint: according to the files I downloaded, the size of Autodesk.AutoCAD.Interop.dll is 140KB (2010) and 144KB (2011).
Edited by: norman.yuan on May 7, 2010 7:43 PM