views:

475

answers:

1

I have a c++/cli dll that I load at runtime and which works great in debug mode. If I try and load the dll in release mode it fails to load stating that one or more dependencies are missing. If I run depends against it I am missing MSVCR90.DLL from MSVCM90.DLL. If I check the debug version of the dll it also has the missing dependency, but against the debug (D) version.

I have made sure debug/release embed the manifest file. I read something about there being issues with the app loading the dll being build as Any CPU and the dll being built as x86, but I don't see how to set them both to x86.

I am using VS2010.

Anyway, I've been messing around for a while now and have no idea what is wrong. I'm sure someone out there knows what is going on. Let me know if I need to include additional info.

alt text

UPDATE:

This ended up being the resolution to my problem: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/07794679-159b-4363-ae94-a68fe258d827

+1  A: 

MSVCR90 is the runtime for Visual Studio 2008. If you are running your application on your development PC, then you should have the debug and release runtimes installed (as part of Visual Studio) but it is possible something has gone awry with your install, or that VS2010 doesn't actually include the older runtimes. If you're trying to run the Release on a different PC, then it just needs the runtime installed.

Either way, you may be able to fix it by installing the Visual Studio 2008 redistributable - but make sure you get the right download for your PC (x86 or x64).

In previous versions of VS, you needed the runtime for the version you were compiling with, so if VS2010 follows this precedent you'd need MSVCR100, not MSVCR90 - which suggests that you may not have recompiled the dll with VS2010 - doing so may be another approach to get it running on your PC (using the redist that is in your VS2010 install) but beware that you will still need other users to install the appropriate (VS2010) redistributable on their PC.

As for "Any CPU" versus "x86", this is a problem only on a 64-bit computer. On those systems a 64-bit application can't link dynamically to 32-bit dlls. If you compile your application as "Any CPU" it will be JIT compiled to be 64-bit on an 64-bit OS, so will crash if it tries to call any 32-bit dlls directly. THe solution is to build the application targeting "x86" as that forces the JIT compiler to generate 32-bit code (even on a 64-bit machine) and thus ensures compatibility with the dll you wish to call. If the DLL is a managed assembly, then you can use Any CPU on both the app an dll as they will both be JITted to the same format.

Jason Williams
This is on my dev box and I'm targeting .net 3.5 with VS2010 which ends up using VS2008 to build. I'm not sure if it's some weirdness going on there or not. So it is correct that it's using the 90 versions of the dlls.
Mitch
This was an answer to my question, but didn't solve my problem. I still don't know what is wrong with my dev environment, but I can't load those dlls in release mode. They work fine on other machines with the vc++ runtime CRT installed.
Mitch
@Mitch. Sorry to hear that. All I can suggest is to try (re)installing the redist package on your PC (the dlls are included in the Visual Studio install, but it does not actually install the redist package, so it is slightly different than you'd get on a user's PC) - if that doesn't work, the only thing I can think of is to reinstall Visual Studio. It doesn't sound like a problem with your build, because you say it runs fine on other PCs - so it's definitely something about your PC that is different.
Jason Williams