我做了很多研究来解决我在 Visual Studio 2008 中收到的链接器错误。代码在 VS2010 中运行良好,但我也需要它在 VS2008 中工作。
链接器在构建项目时为我提供以下输出:
error LNK2028: unresolved token (0A000459) "void __cdecl __ExceptionPtrCopy(void *,void const *)" (?__ExceptionPtrCopy@@$$FYAXPAXPBX@Z) referenced in function "public: __thiscall std::_Exception_ptr::_Exception_ptr(class std::_Exception_ptr const &)" (??0_Exception_ptr@std@@$$FQAE@ABV01@@Z)
error LNK2019: unresolved external symbol "void __cdecl __ExceptionPtrCopy(void *,void const *)" (?__ExceptionPtrCopy@@$$FYAXPAXPBX@Z) referenced in function "public: __thiscall std::_Exception_ptr::_Exception_ptr(class std::_Exception_ptr const &)" (??0_Exception_ptr@std@@$$FQAE@ABV01@@Z)
error LNK1120: 2 unresolved externals
我认为当我想从 c++ 到 c++/cli 通信时会发生错误。我有一个托管类,它包含对托管对象的引用。
ManagedWrapper.h:
class ManagedObjectWrapperPrivate
{
public:
msclr::auto_gcroot<ManagedObject^> obj;
}
public class ManagedWrapper
{
...
private:
ManagedObjectWrapperPrivate *objWrapper;
}
然后在构造函数中初始化对象和对象包装器。但是,对于本机 c++ 代码看不到托管对象,我重新声明(在 NativeWrapper.h 中)如下:
class ManagedObjectWrapperPrivate;
因此,本机类不会知道 ManagedObjectWrapperPrivate 持有的托管对象。
这在 VS 2010 中工作正常,但在 VS2008 中似乎不起作用
如果需要,我很乐意提供更多信息。