System.DllNotFoundException: Unable to load DLL on window 2003
Asked Answered
T

5

11

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"

Tooley answered 19/1, 2010 at 12:42 Comment(5)
Is lib.dll present in the application directory?Moltke
yes, it is, but the error is still appear..does any one know how to fix..i feel very frustrated...Tooley
Is lib.dll built in debug as well? It may be trying to link against the debug C++ runtime which won't be installed if Visual Studio isn't installed on the Windows 2003 machine.Dressler
@shf301: Good thinking, that has bitten me too many times :)Moltke
i don't have source code for lib.dll..my project does copy lib.dll to debug folder, when i click on debug.Tooley
A
14

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.

Arneson answered 19/1, 2010 at 13:19 Comment(0)
H
7

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.

Hamlet answered 19/1, 2010 at 13:3 Comment(2)
Thanks! Your answer just helped me out in a big way. Dependency Walker got right to the root of the problem.Maddeu
Thats the ticket. I have been struggling with this issue in unity3d for a week now.Wavell
D
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...

Deceitful answered 19/1, 2010 at 18:52 Comment(0)
L
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.

Lief answered 19/1, 2010 at 19:39 Comment(0)
P
0

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.

Psychomotor answered 8/6, 2021 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.