LNK2028 LNK2019在托管函数中的非托管函数调用上出错

时间:2013-04-09 19:40:36

标签: unmanaged managed-c++

我有一个非常简单的托管(CLI Interop)函数调用非托管函数:

void ManagedZigBeeTransport::StartDiscovery(void)
{
    std::list<sDeviceEndPoint> devices = zbTransport->startDiscovery();
}

其中zbTransport是一个无人对象。我在这个非托管对象中有几个方法的例子,它们在类似的托管包装器中调用而没有问题,它们都可以工作。但是,它们没有返回值。这个。

它给了我可怕的

CppBridgeTransports.obj : error LNK2028: unresolved token (0A00033B) "public: class std::list<struct _sDeviceEndPoint,class std::allocator<struct _sDeviceEndPoint> > __thiscall ZBTransport::startDiscovery(void)" (?startDiscovery@ZBTransport@@$$FQAE?AV?$list@U_sDeviceEndPoint@@V?$allocator@U_sDeviceEndPoint@@@std@@@std@@XZ) referenced in function "public: void __clrcall CppBridge::ManagedZigBeeTransport::StartDiscovery(void)" (?StartDiscovery@ManagedZigBeeTransport@CppBridge@@$$FQ$AAMXXZ)

接着是

CppBridgeTransports.obj : error LNK2019: unresolved external symbol "public: class std::list<struct _sDeviceEndPoint,class std::allocator<struct _sDeviceEndPoint> > __thiscall ZBTransport::startDiscovery(void)" (?startDiscovery@ZBTransport@@$$FQAE?AV?$list@U_sDeviceEndPoint@@V?$allocator@U_sDeviceEndPoint@@@std@@@std@@XZ) referenced in function "public: void __clrcall CppBridge::ManagedZigBeeTransport::StartDiscovery(void)" (?StartDiscovery@ManagedZigBeeTransport@CppBridge@@$$FQ$AAMXXZ)

我无法应用我在这些已经运行的线程中看到的任何信息(有些非常简单,比如添加std :: list&lt;&gt;头文件)。

非托管sDeviceEndPoint结构也在头文件中定义。想法是获得这个非托管的std :: list&lt;&gt;并使用它来加载托管的ArrayList()。但我甚至无法通过这个简单的步骤。我不知道导致问题的原因是什么,std :: list或sDeviceEndPoint结构。后者成功地用于这个非托管到管理桥的其他部分。

有什么想法吗?

是否归因于我不理解返回值的名称修改约定?

1 个答案:

答案 0 :(得分:0)

我很尴尬!我测试了托管代码和非托管代码之间的一系列简单函数,从返回一个简单的int到一个struct,一个struct的向量和一个结构列表。甚至将这些字段作为参数传递。

他们都工作了。

我做错了什么???

白痴说我忘记了我还没有实现原来的愚蠢功能。当然,我的所有测试都已实施!所以我的原始发现函数已经声明但没有实现。 AARRGG!我花了这么多时间。

(我从来没有猜到这是错误信息的原因。)

这可能会因为同样的原因而拯救获得同一组消息的其他人。