I have a piece of code that opens and controls AutoCAD from VB.NET. It was working fine with AutoCAD 2008 and VB.NET 2003 or 2008 on XP. I have since upgraded to Wndows 7 (32 bit), VS 2010, and AutoCAD 2010.
I have downloaded and installed the ObjectARX 2010 sdk.
I have referenced the
Autodesk.AutoCAD.Interop.Common.dll and
AutoDesk.AutoCAD.Interop.dll
from C:\ObjectARX 2010\inc-win32 in my project.
Copy Local for these 2 references is set to True. If I set it to False and try start debugging, it can't find them.
The code I used with AutoCAD 2008 to open a new instance of the application was:
PublicShared oAcad As AutoCAD.AcadApplication
oAcad = New AutoCAD.AcadApplication
This generates the error:
Retrieving the COM class factory for component with CLSID {6D7AE628-FF41-4CD3-91DD-34825BB1A251} failed due to the following error: 80040154
I have also tried the GetObject (with AutoCAD already open) and CreateObject(with AutoCAD not open) methods of invoking AutoCAD as follows:
oAcad = GetObject(, "AutoCAD.Application.18")
oAcad = CreateObject("AutoCAD.Application.18")
These methods generate the error:
Cannot create ActiveX component
I think there is something basic I am doing wrong or is not installed correctly, Anyone know what it is?
Solved! Go to Solution.
Solved by DieterDorin. Go to Solution.
This turned out to be a problem with the AutoCAD 2010 installation. It was not packaged correctly for distribution as a Virtual Application. Once I reinstalled locally with the setup from AutoDesk the application's COM components got propertly registered and the interop assemblies could invoke them.
Now I have a different problem where I get the same errorabout 60% of the time. AutoCAD loads, but often is too slow and results in the same error anyway. Obviiously there is a timeout period which is too quick for AutoCAD to load and register as an ActiveX component.
I will close this thread an open a new one for the problem of getting an error of
Cannot create ActiveX Component
before AutoCAD has finished loading when it is slow to load.