我有一个 dll 文件。我在 Windows 窗体应用程序 (C#) 中使用它没有问题。
现在我想在我的 ASP.NET 网站 (C#) 中使用,并且像我的 Windows 应用程序一样导入它:
[DllImport( "mydll.dll" )]
static extern int myfunc(int i);
但是当我运行我的网站并使用 myfunc 方法时,它显示了这个错误:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
不知道是什么问题
更多信息:
它是 64 位 dll。我有一个 x64 cpu(Intel core i7)。我没有dll的源代码。我的本地计算机上有一个 IIS,我正在对其进行测试。
最佳答案
您可能在 x64 上运行,并且您的 IIS 未设置为允许 x86 程序集。
在您的应用程序池中启用 32 位 DLL,as described here :
- 右键单击您的应用程序池
- 选择高级设置
- 将“启用 32 位应用程序”的值更改为 true,然后单击“确定”
关于c# - 在 ASP.NET 网站中使用 Dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25579819/