App Does Not Run with VS 2008 Sp1 Dlls, Previous Version Works with Rtm Versions

App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions

I have battled this problem myself last week and consider myself somewhat of an expert now ;)

I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put

#define _BIND_TO_CURRENT_MFC_VERSION 1
#define _BIND_TO_CURRENT_CRT_VERSION 1

into every project you're using. For every project of a real-world size, it's very easy to forget some small lib that wasn't recompiled.

There are more flags that define what versions to bind to; it's documented on http://msdn.microsoft.com/en-us/library/cc664727%28v=vs.90%29.aspx . As an alternative to the lines above, you can also put

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1

which will bind to the latest version of all VC libs (CRT, MFC, ATL, OpenMP).

Then, check what the embedded manifest says. Download XM Resource Editor: http://www.wilsonc.demon.co.uk/d10resourceeditor.htm. Open every dll and exe in your solution. Look under 'XP Theme Manifest'. Check that the 'version' attribute on the right-hand side is '9.0.30729.1'. If it's '9.0.21022', some static library is pulling in the manifest for the old version.

What I found is that in many cases, both versions were included in the manifest. This means that some libraries use the sp1 version and others don't.

A great way to debug which libraries don't have the preprocessor directives set: temporarily modify your platform headers so that compilation stops when it tries to embed the old manifest. Open C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\include\crtassem.h. Search for the '21022' string. In that define, put something invalid (change 'define' to 'blehbleh' or so). This way, when you're compiling a project where the _BIND_TO_CURRENT_CRT_VERSION preprocessor flag is not set, your compilation will stop and you'll know that you need to add them or made sure that it's applied everywhere.

Also make sure to use Dependency Walker so that you know what dlls are being pulled in. It's easiest to install a fresh Windows XP copy with no updates (only SP2) on a virtual machine. This way you know for sure that there is nothing in the SxS folder that is being used instead of the side-by-side dlls that you supplied.

How to select the version of the VC 2008 DLLs the application should be linked to?

_BIND_TO_CURRENT_VCLIBS_VERSION sets the current version in the manifest - or the RTM version if not.
And setting it in the manifest is the correct way to do this.

What you are seeing however is the effects of an assembly policy file :- When the VCRedist package containing the 2008 SP1 runtime is installed, it installs a policy file into the WinSxS store with a bindingRedirect entry that redirects attempts to load the RTM runtime to the SP1 runtime.

So applications that specify the RTM runtime in their manifest will load the SP1 runtime, and applications that specify the SP1 runtime, will load the SP1 runtime.

If you actually DO want to use the RTM runtime, even when the SP1 runtime and policy files are installed, then you need to specify the RTM version in your manifest, AND make use of an application configuration file. Basically "yourappname.exe.config" ( or "yourdllname.dll.2.config" if its an isolation aware dll causing grief).
Application congifuration files can supply a bindingRedirect element that overrides any assembly version specified in the manifest, or policy files.

This config file will tell the OS to load the RTM runtime even if the SP1 runtime is installed :-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<windows>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
<bindingRedirect oldVersion="9.0.30729.1" newVersion="9.0.21022.8"/>
</dependentAssembly>
</assemblyBinding>
</windows>
</configuration>

Note: oldVersion is allowed to be a range: oldVersion="9.0.30729.1-9.1.0.0"

See: Application Configuration Files documented on MSDN.

Difference between RTM vs SP1 of Visual Studio 2008

SP1 is newer. Install it on your other machine: http://www.microsoft.com/downloads/en/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

Installing MS debug DLLs for remote debugging

The debug DLLs are provided in the vc\Debug_NonRedist subdirectory. Properly deploying them is explained in this MSDN Library article.

How to upgrade VS2008 from version 9.0.21022.8 RTM to 9.0.30729.4462 QFE (to hopefully resolve __forceCRTManifestCUR error)

Whoops - it looks like I had been totally misled by Microsoft.

It turns out that it is Visual Studio Service Pack 1 that updates the version from 9.0.21022 to 9.0.30729.

I was convinced that I already had SP1 installed because:

a) The About dialog mentioned SP1 explicitly (though this turned out to be .Net 3.5 SP1 not Visual Studio 2008 SP1)

b) Windows Update did not offer SP1 for download, and all of the "Check for update" links route to a page that instructs you to use Windows Update.

Subsequent to my original question, I had managed to get my source-base to build by installing the C++ Feature Pack for VS2008, but nothing would run due to Side-by-Side errors. Eventually it occurred to me that maybe the SP1 had not been installed.

VS2008 SP1 hot-fixes for C++ development: where can I found a comprehensive list?

This page is the only one I'm aware of that resembles anything comprehensive:

https://connect.microsoft.com/VisualStudio/downloads/

Compiling Qt app agains latest VC++ 2008 runtime

This should fix it: App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions



Related Topics



Leave a reply



Submit