C++ – Why won’t the VS2010 native C++ application suddenly start, giving a side-by-side error

cvisual studio 2010visual-studio-2008windows 7

I had to reinstall my system (Win7) after a hardware upgrade. Before the upgrade, I also ran Win7 and VS2010 and my application ran without a problem in both the release and debug versions. Now I compile and link it, but when I try to run it, I get:

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

The event log shows:

Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.

for the particular executable. What is strange to me, is that I see the VS2008 runtime among the installed programs in the control panel. Even stranger is the fact that it used to work a week ago on my old installation. I had VS2008 there before I upgraded to VS2010 so maybe that's the reason. Anyway, I also don't understant why doesn't VS2010 link my binary against the newest (VC10) runtime libraries, instead relying on the (nonexistent?) VC9.0 ones. What can I do to get my application to run?

EDIT: I include the output from sxstrace here. There were a few references to the executable but they most look the same and I selected the 32bit one, since the application is built as 32bit:

F:\cci\Debug>sxstrace Trace -logfile:trace.etl
Tracing started. Trace will be saved to file trace.etl.
Press Enter to stop tracing…

F:\cci\Debug>sxstrace Parse -logfile:trace.etl -outfile:sxs.out
Parsing log file trace.etl…
Parsing finished! Output saved to file sxs.out.

The contents of sxs.out:

Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = Wow32
CultureFallBacks = en-US;en
ManifestPath = F:\cci\Debug\gui.exe
AssemblyDirectory = F:\cci\Debug\
Application Config File =
INFO: Parsing Manifest File F:\cci\Debug\gui.exe.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
INFO: Resolving reference for ProcessorArchitecture WOW64.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.DLL.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
INFO: Resolving reference for ProcessorArchitecture x86.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at F:\cci\Debug\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at F:\cci\Debug\Microsoft.VC90.DebugCRT.MANIFEST.
INFO: Attempt to probe manifest at F:\cci\Debug\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at F:\cci\Debug\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.

Best Answer

The "VS2008 runtime" that shows up among the installed programs in Control Panel doesn't include the debug runtime. It's the redistributable runtime, so it has only the 'release' version of the runtime. But since you had VS 2008 installed on your machine before the reinstallation and that's why it worked before - the debug runtime is included with the dev tools.

Some options to fix the problem:

  • reinstall VS 2008 (I think VC++ Express 2008 will suffice if you no longer have access to another)
  • rebuild the program with VS 2010 (or whatever version you'd like)

If you want your program to be usable by people who don't have the tools installed (which may include you), you should consider building it in release mode and/or building with the statically linked runtime.