System.DllNotFoundException: Unable to load DLL on window 2003

一个人想着一个人 提交于 2019-11-29 09:02:35

问题


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"


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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...



来源:https://stackoverflow.com/questions/2093485/system-dllnotfoundexception-unable-to-load-dll-on-window-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!