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"

Rick
  • 129
  • 1
  • 1
  • 4
  • Is `lib.dll` present in the application directory? – leppie Jan 19 '10 at 12:44
  • yes, it is, but the error is still appear..does any one know how to fix..i feel very frustrated... – Rick Jan 19 '10 at 12:49
  • 1
    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. – shf301 Jan 19 '10 at 12:51
  • 1
    @shf301: Good thinking, that has bitten me too many times :) – leppie Jan 19 '10 at 12:54
  • i don't have source code for lib.dll..my project does copy lib.dll to debug folder, when i click on debug. – Rick Jan 19 '10 at 12:56

5 Answers5

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
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.

Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
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...

Community
  • 1
  • 1
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
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.

wj32
  • 8,053
  • 3
  • 28
  • 37
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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tratak
  • 138
  • 1
  • 9