Can't load DLL due to dependency issue with Visual C Runtime DLL
I'm trying load a 3rd party DLL but I get an error when attempting to load it. Opening it in Dependency Walker shows that the DLL simply relies on kernel32.dll and msvcr90.dll. However, I get the following err开发者_C百科or in Dependency Walker when opening this DLL: Error The Side-by-Side configuration information for [full path to the dll that I am loading] contains errors. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001).
The only copy of msvcr90.dll that exists on the system is one that I copied into the directory that contains my third party DLL. I ran into a very similar problem on another machine and installing the Visual C++ 2008 Redistributable package from Microsoft fixed it. However, I really need to get to the bottom of this as I can't install the redistributable package on all machines that I need this to run on.
I've also tried opening the third party DLL in Visual Studio and examined its manifest. In it I can see that it explicitly is dependent upon the SP0 version of the Visual C Runtime library:
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
However, copying that exact version of the DLL to the machine with the problem still doesn't fix it. What gives?
Ok, I figured it out. I had to include a copy of the Microsoft.VC90.CRT.manifest file. Normally, you can get this from the [Visual Studio 9.0 install dir]\VC\redist\x86\Microsoft.VC90.CRT directory. However, I had SP1 of Visual Studio installed which had slightly different versions of these files. I ultimately extracted the appropriate file from the redistributable package from MS. Obviously if I had another 3rd party DLL that depended upon a different version of the msvcr90.dll I would be in trouble. I guess this is why Microsoft created the side-by-side thing to begin with.
In short (for any potential Googlers in the future), you have two options:
- Install the Visual C++ 2008 Redistributable package (just Google that term, you'll find it)
- Or manually copy the necessary DLLs to your application directory including the .manifest file
精彩评论