加载本机 dll 时抛出 ExecutionEngineException

发布于 2024-08-28 18:02:50 字数 480 浏览 2 评论 0原文

我有一个使用本机 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰沐子 2024-09-04 18:02:50

好吧——问题有点模糊。显然,一位同事修改了本机 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文