Thursday, May 29, 2008

Manifest Hell

Visual Studio 2005 SP1 has different CRT (C Run-time) and MFC libraries than non-SP1 Visual Studio 2005 does (also known as VS2005 RTM, or release to manufacturing). This can wreak havoc in light of XP's strong support for (and enforcement of) SxS (side-by-side) DLLs, which allows different applications to use different versions of the same DLL. Or, in the more complex case I encountered, a single application may end up needing to dynamically link to both the RTM version of MFC and the SP1 version of MFC.

I ran into this while trying to use some ActiveX controls out of National Instruments' Measurement Studio. Measurement Studio needed the RTM version of MFC, but my Visual Studio 2005 SP1 would only create applications with the SP1 version of MFC. And they conflicted, generating "activation context" errors.

To handle SxS, Visual Studio 2005 introduced the concept of manifest files, which specify precisely which version(s) of which DLL(s) are required. There is even a mechanism to automatically promote to using later versions of required DLLs. No matter the combination, I couldn't get my MFC application to work with Measurement Studio, because I of course did not have the source code to Measurement Studio to recompile it against the SP1 version of MFC. As one blog author put it, in the course of trying to solve DLL Hell (for the user), Microsoft ended up creating Manifest Hell (for the developer).

So my solution was to use ATL instead, and let Measurement Studio use the RTM version of MFC.

No comments: