I am in process of converting some of my application’s sub-applications over to the new MFC feature pack. They’re rather simple applications that I think will work nicely under the Office 2007 Ribbon framework. As such, I’ve run into some headaches with the new applications and have submitted some bugs to microsoft via Microsoft Connect.
Today’s issue is regarding the version of the MFC and MSVCR90 libraries that a new application will link to.
The VC9 (Visual Studio 2008) compiler will always use the first version of MSVCR90 and MFC (9.0.21022.8). Please see here for more details. In order to override this, the developer must #define _BIND_TO_CURRENT_VCLIBS_VERSION in some place like stdafx.h (near the top). This will make the linker link to the current/latest version of MSVCR90 and MFC90 (9.0.30729.1).
The MFC feature pack pretty much requires the new libraries that are shipped with SP1 of Visual Studio 2008. But, the MFC Application Wizard, when it creates a new project, does not include this #define anywhere. So the manifest will bind to 9.0.21022.8 of the libraries. At first, it may appear ok since the Windows SxS system will use the 9.0.30729.1 version if it’s found: it will be found on the developer’s machine since Visual Studio was installed.
However, if you move the application to another computer where 9.0.30729.1 is not installed (nor should anyone think it should be since the application is bound to 9.0.21022.8), then it won’t work. If the earlier version is found, it may start to run, but will run into issues when the later libraries are required.
The fix is to always, ALWSAYS #define _BIND_TO_CURRENT_VCLIBS_VERSION at the top of stdafx.h for new MFC projects using Visual Studio 2008 SP1.
I have submitted this issue to Microsoft. You can view the issue here.