简体   繁体   中英

Why won't my VS2010 native C++ application suddenly start, giving a side-by-side error?

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.

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.

Microsoft.VC90.* Debug *CRT

Yes, that DLL won't be available on your machine, you didn't install VS2008. You can't get it from Microsoft either, it is a non-distributable file.

Do fret a bit about why your VS2010 project has a dependency on the VS2008 version of the CRT, it is pretty unhealthy. And a pretty unpleasant deployment headache, reason enough to fix that.

Short from installing VS2008, you could create a Setup and Deployment project on another machine that has VS2008 installed to get the debug DLLs on your new machine. Project + Properties + Prerequisites, untick the .NET framework. Project + Add + Merge Module to add the debug merge modules for the DLLs and policy files from c:\program files\common files\merge modules.

I have had a case where a COM DLL was being built (for development purposes only) in the VS 2008 environment, when other components on the project used a newer version of Visual Studio. This set of instructions detail how to install just the VS 2008 VC++ runtime files using the Visual Studio 2008 Installer, without having additional unnecessary software installed. It is recommended that these steps be followed before installing Visual Studio 2010 or any subsequent VS version, if possible.

  1. Run the Visual Studio 2008 installer. The ISO can be downloaded using MSDN Subscriber Downloads.
  2. At the Visual Studio 2008 Setup dialog, select Install Visual Studio 2008
  3. "Microsoft Visual Studio 2008" dialog appears. Click Next
  4. "Start Page" - Accept the license terms, click Next
  5. "Options Page" - select Custom, click Next
  6. "Options Page" - deselect EVERYTHING. Navigate to: Microsoft Visual Studio 2008 Professional -> Language Tools -> Visual C++ -> Visual C++ Tools. Check "Visual C++ Run-Time Libraries" (and everything else below is checked). Click Install
  7. --> Install proceeds.
  8. "Finish Page" appears. Click Finish.
  9. "Microsoft Visual Studio 2008" dialog appears again. Click Exit Following installation, uninstall the things that were installed without the option not to have them installed. From Add/Remove Programs (Programs and Features), uninstall the following:
    • Microsoft SQL Server Database Publishing Wizard 1.2
    • Microsoft Visual Studio Web Authoring Component
    • Microsoft Document Explorer 2008
    • Microsoft Windows SDK for Visual Studio 2008 .NET Framework Tools
    • Microsoft SQL Server Compact 3.5 ENU
    • Microsoft SQL Server Compact 3.5 Design Tools ENU
    • Microsoft Visual Studio 2008 Remote Debugger
    • Microsoft Visual Studio 2008 Remote Debugger Light (x64) -ENU
    • Microsoft Windows SDK for Visual Studio 2008 Tools
    • Microsoft Windows SDK for Visual Studio 2008 Headers and Libraries
    • Microsoft Windows SDK for Visual Studio 2008 SDK Reference Assemblies and IntelliSense
    • Microsoft Visual Studio 2008 Prerequisites
    • Microsoft SQL Server 2008 Management Objects
    • Microsoft Windows SDK for Visual Studio 2008 SP1 Express Tools for Win32
    • Microsoft Windows SDK for Visual Studio 2008 SP1 Express Tools for .NET Framework - enu

Following uninstallation of these products, the only two products that should be left (from the VS 2008 installation) are:

  • Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729
  • Microsoft Visual Studio 2008 Professional Edition - ENU

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM