AcadApplication w/2010使用
大家好希望有人能对这个问题有一些见解,我的应用程序从AutoCAD 2009到2010。。。
我的应用程序使用AutoCAD 2009类型库&ObjectDBX Common 17.0类型库。。。使用以下协议,我能够打开并使用AutoCAD(视情况而定)
Private AutoCAD_Instance As AcadApplication
Try
AutoCAD_Instance = GetObject(, "AutoCAD.Application")
Catch
AutoCAD_Instance = CreateObject("AutoCAD.Application")
End Try
安装2010后,在执行“CreateObject”时出现以下错误(即使AutoCAD处于打开状态,GetObject也会失败)
Exception Type : System.InvalidCastException
Unable to cast COM object of type 'Autodesk.AutoCAD.Interop.AcadApplicationClass' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{8F17437C-2EFB-4FC4-8188-EEFA50FE7147}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
一旦我替换了对2010版本的引用,这个例外就消除了。。。如果可能的话,我希望能够避免这种情况。。。
顺便提一下,当加载2010引用并尝试运行2009时,我遇到了类似的错误。。。
有什么想法吗?
非常感谢! 只是想让人们知道,我已经能够通过重新定义“XXXXX为对象”(vs AcadApplication)来实现这一点。。。
我想这是晚装吧?它整体工作,除了与。还原“LayerState”时尝试使用的GetInterfaceObject
页:
[1]