带有 C DLL 的 C# 应用程序在首次访问 DLL 时崩溃

发布于 2024-10-31 11:50:40 字数 490 浏览 0 评论 0原文

我有一个 C# 应用程序和一个 C DLL,它们都是我编写的,并且都可以在我尝试过的一些 W7(64 位)和 XP(32)机器上运行。今天我在另一台机器 (XP) 上安装了 app/dll 集,它在第一次调用 DLL 时崩溃了。我已经用 return(0) 替换了 DLL 中调用的代码,但它仍然崩溃。 我已经在几台机器上使用这个 app/dll 集几天了,没有出现任何故障,但现在我很困惑,因为它只是访问 DLL 就死掉了。有什么想法吗?

自我原来的帖子以来添加了注释: 我根据下面的建议学到了一些东西...... 1.异常错误消息为“...并行配置不正确...”。 谷歌搜索似乎表明这是一个与电脑没有安装相关的问题 正确(兼容)的环境;但是,请注意,此 C# 应用程序已在此运行 过去在PC上还好(不同的是现在DLL是用VS2008构建的) 而不是 Cygwin/MinGW/GCC)。 2. dependency walker 告诉我找不到文件 IESHIMS.DLL。我没有 知道这个文件的用途,但显然我需要它。

I have a C# application and a C DLL both of which I wrote and both of which work on a few W7 (64-bit) and XP (32) machines I've tried it on. Today I installed the app/dll set on yet another machine (XP) and it crashes on the first call to the DLL. I've replaced the code in the DLL that gets called with return(0) and it still crashes.
I've been using this app/dll set for a few days on a few machines without a glitch, but now I'm stumped 'cause it dies just accessing the DLL. Any ideas?

Added note since my original post:
I've learned some things based on suggestions below...
1. the exception error message is "... side-by-side configuration is incorrect...".
Googling seems to indicate that this is an issue related to the PC not having the
correct (compatible) environment; however, note that this C# app has run on this
PC just fine in the past (difference being that the DLL is now built with VS2008
rather than Cygwin/MinGW/GCC).
2. dependency walker tells me that the file IESHIMS.DLL cannot be found. I have no
idea what this file is for, but apparently I need it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

国粹 2024-11-07 11:50:40

IESHIMS.DLL 依赖项几乎出现在我在依赖项遍历器中打开的每个文件中,并且它从来都不是任何问题的根源 - 您几乎可以肯定忽略它。

您应该检查以确保您拥有正确版本的 Visual C++ Redistributable,并且您可能还想检查此问题 - 并排配置错误 (Microsoft.VC80.CRT v8.0.50608.0) 以确保这不是适用于您。

最后,您应该确保您的 C# 应用程序针对特定体系结构(本机 dll 构建的体系结构)而不是“任何 CPU”,因为“任何 CPU”将意味着该程序将作为 64 位运行或 32 位应用程序,具体取决于您运行它的机器,这将导致在 64 位机器上尝试加载 32 位本机 dll 时出现问题。

如果您的应用程序以前在使用不同的运行时编译时可以工作,那么听起来 Visual C++ 运行时根本没有安装在该特定计算机上 - 您永远不应该假设它是安装的,但是在许多计算机上它已经由另一个应用程序安装了。

更新:以下是Microsoft Visual C++ 2008 可再发行组件包 (x86)

The IESHIMS.DLL dependency appears for pretty much every file I open in dependency walker and its never been the source of any problems - you can almost certainly ignore that.

You should check to make sure that you have the correct version of the Visual C++ Redistributable, and you might also want to check this question - Side-by-side configuration error (Microsoft.VC80.CRT v8.0.50608.0) to make sure that this is not applicable to you.

Finally, you should make sure that your C# application targets a specific architecture (the one that the native dll was built against) rather than "Any CPU", as uisng "Any CPU" will mean that the program will run either as a 64 bit or 32 bit application depending on what machine you run it on, which will cause problems on 64 bit machines attemtping to load 32 bit native dlls.

If your app previously worked when compiled with a different runtime then it sounds like the Visual C++ runtime is simply not installed on that specific machine - you should never assume that it is, however on many machines it has already been installed by another application.

Update: Here is a link to the Microsoft Visual C++ 2008 Redistributable Package (x86).

夕嗳→ 2024-11-07 11:50:40

也许缺少 C dll 的依赖项 (dll)(也许是 C++ 运行时?)?您可以在所在计算机上的 dll 上运行 dependent.exe : http://www.dependencywalker.com/您的应用程序崩溃并查看是否缺少任何依赖项。

您是否还可以在第一次调用 C dll 时添加异常处理以捕获并显示任何异常?

Perhaps there is a missing dependency (dll) for the C dll (perhaps a C++ runtime?)? Can you run depends.exe : http://www.dependencywalker.com/ on the dll on the machine where your application crashes and see if there are any missing dependencies.

Could you also add exception handling around your first call to the C dll to catch and display any exceptions?

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