Wednesday, April 4, 2007

C-Runtime Libraries, DLL Hell and Side-by-Side Deployment

Starting from Windows XP, Microsoft has created a new "side-by-side" deployment model for native libraries as its latest attempt to solve the "DLL Hell" mess. The concept is pretty much the same as versioning in the managed world: libraries are versioned and signed, then installed in a global cache (WinSxS folder). Different versions of the same library can co-exist in the cache. A manifest is embedded in executable files to identify the version of the library the application was built with. C-Runtime libraries (MSVCRTxx.DLL, MSVCPRTxx.DLL, etc) are treated the same way. The process will throw a nasty error message if the executable or any DLL doesn't have a manifest embedded. If a third party library or an old DLL lying around doesn't have manifest built in, MT.EXE can be used to embed the manifest xml into the DLL directly:

    mt /outputresource:yourlib.dll;#2 -manifest yourlib.dll.manifest
More references in MSDN: