views:

605

answers:

5

Hi all,

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"

A: 

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
+3  A: 

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
A: 

Thanks , I used Dependency Walker and found lib.dll link to 4 dll KERNEL32.DLL, MSVCR90D.DLL, NTDLL.DLL, LIB.DLL , then i do a quick search on my 2003 server. It couldn't find the file "MSVCR90D.DLL", then i downloaded and put MSVCR90D.DLL in window/system32 folder, but it still doesn't work.

Please suggest me litte bit detail how to fix it..

Rick
edit your original question, don't post questions as answers.
Sam Holder
MSVCR90D.DLL is the debug version of the C++ run time. Just copying it in won't work because it needs to be registered with Side-by-Side. I'm not exactly how sure you would do that. Is there anyway you can get a non-debug build of the DLL?
shf301
A: 

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

Sam Holder
A: 

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