By Barbara Han
We got a partner’s report saying calling the code mentioned in this blog’s title fails with an exception as below:
System.Runtime.InteropServices.COMException (0x80040111): Problem in loading application
He is using the "Autodesk SymBBAuto 4.0 Type Library" and the "Autodesk AutoCAD Mechanical 2.0 Type Library" from the ACM 2013 Version, and his code is simple:
mAcadApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication; mSymMgr = (McadSymbolBBMgr)mAcadApp.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr");
Nothing seems to be wrong obviously. Several of my colleagues got some time looking into this case, but finally I became the only one who would take care of this because they were off (for meeting or vacation). No surprise there were a long discussion history in this case – more than 20 emails, and I had no time to read all of them, so just jumped in to answer the last query about how to use VBA to check if those ACM interfaces can be called. I installed ACM 2013 on a 32bit machine for doing the test, and all things seem to work.
I got reminding from the partner that my colleague, Gary Wassell reproduced it with a specific installing order: AcadM 2013 first, AcadM 2012 second, and he is using 64bit system. This is a real headache for me, because I rarely used AcadM so there is no any prepared test environment. Nobody has such configure. I had to go forward to install those two versions in the acquired order, and needed SDK. It took me a couple of days to set up everything, because sometimes I was interrupted by responding to other requests. I created a test sample with just a few of lines of code of calling ACM API. The problem is not reproduced. It’s weird.
Afterward the partner passed two sample projects to me and I found two samples are using same code, but referring to different type library version – one version is ACM 2012, another is ACM 2013. If running the 2012 version of sample app one time, the 2013 version of sample app can’t work. I ever suggested a method about running <AutoCAD 2013 installation path>\Acadm\enu\symbbautoreg.exe file every time executing 2013 version of sample app, but the partner said he got another error when starting ACM 2013.
I had to documented this detailed and asked our development team. They gave me the answer that I want:
"When there are ACM2012 and ACM2013 installed in the same machine, the code for ACM2013 should be different, like this:
mAcmApp = (AcadmApplication)mAcadApp.GetInterfaceObject("AcadmAuto.AcadmApplication.2");
//Get symbol manager
mSymMgr = (McadSymbolBBMgr)mAcadApp.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr.4");
Your original code works if there is only ACM2013 installed, this is the designed behavior."
Tricky? Yeah. I wrote down it here because it’s not mentioned in help document. Hope you can find this without any time wasting in setting up test and asking, like me. :)