下面一行是在C#GUI生成运行时错误:调用从C#中的C++的.dll引发运行时错误
int x = myclass.number_from_dll();
我使用Microsoft Visual Studio 2008
中的代码C#是:
class myclass
{
[DllImport("strat_gr_dll.dll", EntryPoint = "number_from_dll")]
public static extern int number_from_dll();
}
在C++的.dll的代码是:
// This is an example of an exported function.
DLL int number_from_dll(void)
{
return 42;
}
从.NET运行时错误是:
An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)
您是否用友好名称导出该功能? – 2010-08-02 19:13:16