Debugging automatic manifest files

In Whidbey, the Visual C++ libraries team has moved to a model where the various C++ runtime dlls (msvcr80.dll msvcp80.dll atl80.dll etc) are found using Fusion instead of the classic dll resolution that we all know. What this means is that:

  1. You have to deal with manifests.
  2. You have a prerequisite setup to run.

I have wasted a few days of my life on #1, so I figured I would share some insights. First, the way this works is that your dll/exe gets a new resource of type 'RT_MANIFEST'. You can look at this in the resource editor. Just open the exe/dll as a file. This manifest is generated by mt.exe/link.exe. The linker combines manifest dependency directives from the various .lib/.obj files to generate the manifest. These linker directives are from code inside header files of the ATL/MFC/CRT. For example, this is in crtdef.h:

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.VC80.DebugCRT' version='' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'\"")

If you run into problems where your dll is depending on the CRT/ATL/MFC when it shouldn’t, you will want to use 'Dumpbin /directives <lib/obj>'. This will list all of the linker directives in the lib/obj. Look for manifestdependency directives, and you can figure out which lib/obj is causing you problems.