加载本机 dll 时抛出 ExecutionEngineException
我有一个使用本机 32 位 DLL 的 32 位 .net 应用程序 通过 DllImport()。原生 DLL 是我们的内部文件分析库,我需要使用它,因为如果人们更新它(其他软件使用它),将其移植到 C# 将会出现问题。
问题是,当我尝试执行本机 DLL 中的任何方法时,我会抛出 System.ExecutionEngineException 异常。事实上,我已将托管应用程序简化为仅调用本机方法的简单测试器,但它仍然失败。
我使用的是 64 位 Windows 7,但这并不重要,因为我将所有内容都编译为 32 位二进制文件。
同样有趣的是,当我查看 Dependency Walker 中的本机 DLL 时,它显示它找不到 msvcr90.dll - 但是当我在 Dependency Walker 中打开任何其他本机 DLL 时,它可以找到它们引用的 msvcr90 .dll就好了。本机 DLL 的编译中是否存在一些错误,导致其 DLL 引用混乱?
I have a 32-bit .net application that uses a native 32-bit DLL
via DllImport(). The native DLL is our internal file analysis library, and I need to use it as porting it to C# would be a problem if people update it (other software uses it).
The problem is that when I try to execute any method in the native DLL I get a System.ExecutionEngineException thrown. In fact, I've reduced the managed application to a simple tester that just calls a native method, but it still fails.
I am on 64-bit Windows 7, but that should not matter as I'm compiling everything as 32-bit binaries.
What is also interesting, when I look at the native DLL in the Dependency Walker, it shows that it can't find msvcr90.dll - but when I open any other of our native DLLs in the Dependency Walker, it can find their referenced msvcr90.dll just fine. Can there by some wrongness in the compilation of native DLL that messes up its DLL references?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧——问题有点模糊。显然,一位同事修改了本机 DLL 的方法以包含一个具有默认值的参数(C++ 可以很好地处理),但是,正如我们所知,C# 3.5 不会。为该参数提供值后,一切正常!
OK - the problem was a little bit misty. Apparently a colleague modified the native DLL's method to contain one parameter with default value (that C++ handles just fine), but, as we know, C# 3.5 does not. After supplying a value for that parameter, everything worked fine!