Windows Side-by-Side Assemblies

Before Windows Side-by-Side Assemblies, or WinSxS, (introduced with Windows XP in the Windows\WinSxS directory) the world was plunged into "DLL Hell". That is to say run-time DLLs would all need to be copied into a path (such as System or System32) that is in the global application loader module search path. Commonly people publishing software would also include copies of these DLLs in the local application directory just to be safe, in case the client did not have the necessary runtime already installed, or there was a version mismatch.

MFC 8 (through VC 2005) makes use of WinSxS. It embeds a manifest into the compiled application which describes the runtime it requires to operate properly. For example:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT"
version="8.0.50608.0" processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.DebugMFC"
version="8.0.50608.0" processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</
assembly>

The application loader will read this manifest and attempt to locate the correct files, instead of looking for the name of the DLL in the available search paths. If you're missing the MFC 8 runtime then the loader will complain that the correct application environment has not been established and the program will not load. The old quick fix of copying the runtime into the local application directory will not fix this because the loader looks for the runtime DLLs (described by the manifest) in the Windows\WinSxS directory only. Therefore it is there to which the runtime must be copied! Luckily no additional 'registration'/registry editing is required!

The following example deals with the MFC 8 and VC 2005 Debug runtime (look here for the Release build):

In addition to the DLLs, the relevant files and directories from the 'Manifests' and 'Policies' directories must also be copied to the computer requiring the runtime. The directory structure must be maintained! The operative strings are:

  • x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c
  • x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_c8452471

Once all the files have been copied, all MFC 8/VC 2005 applications will be loaded! (Whether they run perfectly depends on the rest of the code...)

For an example of the directories and files that need to be copied, see this. It could be inflated upon the Windows directory while maintaining its structure.

Comments

Thank you!

You r pro!
Thank you for your very comprehensive solution!
I wish I met your article sooner!