System.DllNotFoundException:无法在 Windows 2003 上加载 DLL

发布于 2024-08-18 08:21:09 字数 225 浏览 4 评论 0原文

我在我的c#项目中使用了c++ dll,它在我的window xp机器上运行良好,但是当我在window 2003服务器(x64)上复制我的调试项目时,我收到了下面的错误,任何人都可以告诉我这是什么问题吗?我该如何解决它。

感谢

“System.DllNotFoundException:无法加载 DLL 'lib.dll':此应用程序无法启动,因为应用程序配置不正确。重新安装应用程序可能会解决此问题”

I have c++ dll using in my c# project, It ran fine on my window xp machine, but when i copy my debug project on window 2003 server (x64), i received error below, can any one tell me what is this problem, and how can i fix it.

Thanks

"System.DllNotFoundException: Unable to load DLL 'lib.dll': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem"

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

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

发布评论

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

评论(5

请恋爱 2024-08-25 08:21:09

它抱怨无法找到 CRT dll。首先检查 DLL 是否包含所需的清单。在 Visual Studio 中,“文件”+“打开”+“文件”,选择 DLL 并验证它是否包含 RT_MANIFEST 节点。下一个问题是您无法部署 DLL 的调试版本。它将依赖于 CRT 的调试版本,您无法将其安装在目标计算机上。

部署 DLL 的发布版本或使用 /MT 选项编译 DLL,以便静态链接 CRT。项目 + 属性、C/C++、代码生成、运行时库。如果 DLL 是使用 /clr 选项编译的,则这将不起作用。

It is complaining that it has trouble locating the CRT dlls. First check that the DLL contains the required manifest. In Visual Studio, File + Open + File, select the DLL and verify that it contains an RT_MANIFEST node. The next problem is that you can't deploy a debug build of your DLL. It will have a dependency on the debug version of the CRT, you can't get that installed on the target machine.

Either deploy the Release build of your DLL or compile the DLL with the /MT option so the CRT is statically linked. Project + Properties, C/C++, Code Generation, Runtime Library. This won't work if the DLL was compiled with the /clr option.

別甾虛僞 2024-08-25 08:21:09

对于DLL加载问题,我建议您使用Dependency Walker工具。事实证明,它在处理此类问题时非常有价值,因为它会向您显示确切的问题。

如果您拥有 Visual Studio 2005,则可以在 C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\depends.exe 中找到它。

更新:

MSVCR90D.DLL 是 Visual C++ 运行时 9.0 的调试版本。它只能用于调试目的。我强烈建议您构建库的发行版本,以避免 DLL 加载问题。但是,如果您确实需要部署调试版本,则可以在 C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\x86 中找到所有必需的 DLL。

For DLL loading problem, I suggest you to use the Dependency Walker tool. It has proved to be valuable when dealing with such problems as it will show you the exact problem.

If you own Visual Studio 2005, you can find it in C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\depends.exe.

Update:

MSVCR90D.DLL is the debug version of the Visual C++ runtime 9.0. It should only be used for debugging purpose. I strongly suggest to build a release version of your library in order to avoid the DLL loading problem. However, if you absolutely need to deploy the debug version, you will find all the required DLLs in C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\x86.

醉生梦死 2024-08-25 08:21:09

听起来你还没有在目标机器上安装 Visual C++ 运行时。您可以从此处安装该程序 由于它似乎正在使用这些 dll 的调试版本,也许您还需要首先在发布模式下构建您的应用程序? 这篇文章这个有一些其他建议可能会有所帮助.. 。

sounds like you have not installed the visual c++ runtime on the target machine. You can install that from here As it seems to be using the debug versions of those dlls perhaps you also need to build your app in release mode first? This post and this one have some other suggestions that might help...

傻比既视感 2024-08-25 08:21:09

lib.dll 是 32 位 DLL 吗?您的 C# 程序将在 x64 上本机运行,但无法加载 32 位 DLL。您可以尝试将C#项目的目标CPU更改为“x86”以强制其在WOW64下运行。

Is lib.dll a 32-bit DLL? Your C# program will run on x64 natively but will be unable to load 32-bit DLLs. You can try changing the target CPU of the C# project to "x86" to force it to run under WOW64.

酒废 2024-08-25 08:21:09

我发现当操作系统需要更新时,一些 dll-s 被冻结。
只需检查待处理的更新、安装它们和/或重新启动 Windows。

之后冻结的 dll 被释放,问题就消失了。

I found that some dll-s are frozen when operating system needs an update.
Simply, check pending updates, install them and/or restart Windows.

After that frozen dll-s are freed and problems gone.

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