AcDbObjectId == Operator Causes Crash in Mixed Managed /CLR code
AcDbObjectId == Operator Causes Crash in Mixed Managed /CLR code问题:
Any use of the == operator with AcDbObjectId causes a crash in my AutoCAD 2005 or AutoCAD 2006 code.What can I do to avoid this?Example:
AcDbObjectId ida, idb;
if(ida == idb)
acutPrintf(_T("Ids Match!"));
解答:
The problem with this code is that the managed compiler has a forward declaration of the class which AcDbObjectId wraps called AcDbStub, which it does not have a managed definition for - but links with an unmanaged module that does.From MSDN:
"...can occur when there is only a forward declaration for a type in an MSIL module (compiled with /clr), where the type is referenced in the MSIL module, and where the MSIL module is linked with a native module that has a definition for the type."
The quick solution for this is to give the managed code a dummy definition for this wrapped type by adding:
class AcDbStub {};
in your CPP code before the code you use the comparison with.
页:
[1]