【发布时间】:2010-08-02 19:10:34
【问题描述】:
以下行在 C# GUI 中生成运行时错误:
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)
【问题讨论】:
-
您是否使用友好名称导出该函数?