views:

3725

answers:

3

I've created a DLL project in VS 2005 for native Win32/unmanaged C++, call it myProj.dll. It depends on a 3rd-party commercial DLL that in turn depends on msvcr90.dll (I assume it was built from a VS 2008 project). I'll call it thirdParty.dll.

My DLL project builds just fine in VS2005. I've built a test app (again, VS 2005 Win32 C++) that links to myProj.lib. (As an aside, judging by the small size of the .lib, and by the fact that, at run-time, the app must locate myProj.dll, I'm guessing that the .lib is just a wrapper for a call to loadLibrary() that loads the actual DLL; is that close?)

My problem is that, at run-time, the test app cannot locate msvcr90.dll (nor msvcp90.dll), the dependency on which stems from the thirdParty.dll.

I've installed Microsoft's redist package, and so have all the std (9.0) C++ libraries in c:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_... . What's more, if I point the dependency walker at thirdParty.dll, it happily resolves the references to that location.

But, if I point depends.exe at my test app (.exe) or myProj.dll, msvcr90.dll and msvcp90.dll are not found.

I'm guessing there's something I need to configure in VS2005 so that the .exe or myProj.dll are aware of the location of the 9.0 versions of the std C++ libraries (presumably where the redist package installed them in C:\WINDOWS\WinSxS), but I can't seem to figure out what it is. Am I on the right track?

I note that, if I simply copy the msvc*90.dll files to my app directory, then the dependency is resolved, but I get the run-time error about improper loading of std c++ DLLs, etc.

Thanks immensely in advance.

+1  A: 

I would ask the third party dll people about this.

Tim
Maybe that is the best way. However there might be something corrupt. If that is the case, try a clean windows installation (vmware). That way you can write down everything you are doing to explain them the steps to reproduce this problem.
Wimmel
Thanks, Wimmel. Yeah, that's kind of what I'm thinking I'll do today. And, I am also in touch with the third-party folks. By the way, one thing I neglected to mention is that there is actually a third component--a staticly linked library (.lib) from yet another 3rd party. It includes the clib.
Bikelane
(silly character limit!) ...and so I am forced to build myProj.dll with /MT(d) (again, with VS2005).
Bikelane
+2  A: 

Did you install the SP1 version of the msvc 2008 redist?

It is not a problem if depends.exe cannot find the msvcr90.dll, if you use the microsoft installer it is automatically installed in the correct location, and will be found if your application is run. It does not help if you copy the dll's to your application directory if you do not create a manifest.

But can you tell the exact error message you get?

You can also take a look here and here regarding the manifest.

Wimmel
I did install the SP1 version of msvc 2008 redist.The exact error message is "the application has failed to start because msvcr90.dll was not found. Reinstalling the application ..."This occurs when I build an application that uses myProj.dll.
Bikelane
Maybe this thread: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/6d16ecce-f92b-4c53-a45b-40119c4566a6/ can give you some information to solve the problem.
Wimmel
+3  A: 

This looks like a "Side-by-Side Assemblies" issue to me.

From what I can tell, Microsoft in an attempt to stop the DLL Hell problems of past years has introduced a concept of "Side-by-Side Assemblies".

In a nut shell it means that your application needs to tell Windows which version of the CRT it was designed to work with. When the application is installed Windows will make sure you application gets its own private copy of these DLL files.

To make it all work you need to embed the application's DLL dependencies into the applications Manifest file and attaching it to the project using the Manifest Tool, Input and Output section of the application project settings.

As an example here is the manifest I use for the Zeus for Windows IDE:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
      name="Xidicone.Windows.Zeus for Windows"
      version="3.9.6.69"
      processorArchitecture="X86"
      type="win32" />

  <description>Zeus for Windows</description>

  <dependency>
    <dependentAssembly>
      <assemblyIdentity
            type="win32"
            name="Microsoft.VC80.CRT"
            version="8.0.50608.0"
            processorArchitecture="x86"
            publicKeyToken="1fc8b3b9a1e18e3b" />
    </dependentAssembly>
  </dependency>

  <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="X86"
          publicKeyToken="6595b64144ccf1df"
          language="*" />
    </dependentAssembly>
  </dependency>
</assembly>

Finally, if you plan to make an installer you will need to add the same versions of these DLL files to the application installer or alternatively have your installer run the Microsoft CRT redistributable installer.

FWIW I only found out about this when a user reported that Zeus no longer ran on Windows XP because of a missing MSVCRT runtime DLL file, yet Zeus had been working fine for over 10 years without ever once having to ship with a MSVCRT runtime DLL file.

jussij
I tried copying the content of the manifest from the VS 2008 redist directory into a file in my project's directory, then indicating that it is an "additional manifest file" in my project's manifest properties, which built just fine, but didn't solve the problem.
Bikelane