Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ DUMPBIN实用程序损坏了名称输出_C++_Dll_Dllimport_Dllexport - Fatal编程技术网

C++ DUMPBIN实用程序损坏了名称输出

C++ DUMPBIN实用程序损坏了名称输出,c++,dll,dllimport,dllexport,C++,Dll,Dllimport,Dllexport,我使用DuppBin实用程序从C++ DLL中获取名称,以用于C语言应用程序。 我用一个*yDeScript(dLutExchange)公开C++类成员函数,输出被修改的名字结果是: ?InitPort@CProtocolStack@@QAEEHEPAEKE@Z = ?InitPort@CProtocolStack@@QAEEHEPAEKE@Z (public: unsigned char __thiscall CProtocolStack::InitPort(int,unsigned char

我使用DuppBin实用程序从C++ DLL中获取名称,以用于C语言应用程序。 我用一个*yDeScript(dLutExchange)公开C++类成员函数,输出被修改的名字结果是:
?InitPort@CProtocolStack@@QAEEHEPAEKE@Z = ?InitPort@CProtocolStack@@QAEEHEPAEKE@Z (public: unsigned char __thiscall CProtocolStack::InitPort(int,unsigned char,unsigned char *,unsigned long,unsigned char))
导入相同的函数时,是否需要在C#应用程序中使用全名?
如果没有,哪一部分足以导入?

您只需要此位:

?InitPort@CProtocolStack@@QAEEHEPAEKE@Z
然后你可以这样声明:

[DllImport("your.dll",
    EntryPoint = "?InitPort@CProtocolStack@@QAEEHEPAEKE@Z",
    ExactSpelling = true)]
static extern byte CProtocolStack::InitPort( /* etc. */);

不要。如果你不使用托管C++(可以被称为C++) 直接从C#)中声明接口中的函数
extern“C”
,然后直接使用函数名。破碎罐 从编译器的一个版本更改为下一个版本;
extern

“C”
名称不会

如果您的函数不需要重载,您可以使用
extern“C”
来确定函数名。

@JamesKanze非常正确,但与此同时,我们会尽我们所能。。。COM可能是一个更好的互操作选项。声明函数
extern“C”
,这样名称就不会被损坏。@JamesKanze我认为
extern“C”
不适用于类成员函数。它不适用。您必须提供接口包装函数。但是C++类成员函数可以在C++中使用和<代码>外部“C”< /C>函数,它是C++类的一种实例方法。不能对其进行pinvoke,需要C++/CLI包装。