Side by Side Configuration Incorrect
Getting Started
Most of the developers using assemblies in their application may have faced this issue. While starting an application, we may get an error “This application has failed to start because its side by side configuration is incorrect”.
Introduction
Side by side configuration is a trick for versioning files, in which multiple versions of a file are installed in a single machine. This is achieved through manifest files. E.g.: the C Runtime Library assembly contains three DLLs—msvcr80.dll, msvcm80.dll and msvcp80.dll — and is used by applications when they are built using functions from the CRT library. Side-by-side technology is also known as WinSxS or SxS.
What is Side by Side Configuration?
A side-by-side assembly contains a collection of resources—a group of DLLs, Windows classes, COM servers, type libraries, or interfaces—that are always provided to applications together. These are described in the assembly manifest.
Why is it Important?
In many cases, it is possible to update existing applications to use side-by-side assemblies without having to change the application code. Developers are encouraged to use side-by-side assemblies to create isolated applications, and to update existing applications into isolated applications for the following reasons:
- Side-by-side assemblies reduce the possibility of DLL version conflicts.
- Side-by-side assembly sharing enables multiple versions of COM or Windows assemblies to run at the same time.
- Applications and administrators can update assembly configuration on either a global or per-application configuration basis after deployment. For example, an application can be updated to use a side-by-side assembly that includes an update without having to reinstall the application.
How is it Working?
In the preceding example shown in above picture, both Comctl32.DLL version 6.0 and Comctl32.DLL version 5.0 are in the side-by-side assembly cache and available to applications. When an application calls to load the DLL, the side-by-side manager determines whether the application has a version dependence described in a manifest. If there is no relevant manifest, the system loads the default version of the assembly. For Windows XP, version 5.0 of Comctl32.DLL is the system default. If the side-by-side manager finds a dependence on version 6.0 stated in a manifest, that version is loaded to run with the application.
Is it Related Project Settings?
We have to check if it is possible to resolve with project settings because EXE will run in debug build and fails to start in release build. Change your project settings to not use the runtime library, but this will make the output EXE bigger. (Project Properties -> C/C++ -> Code Generation -> Runtime Library -> use/MT or /MTd depends on your current configuration.) This may work, but it is not the solution for this issue.
Is it OS Related?
No, it is not an OS related issue. Since most of the experiences for this issue are in Vista, initially I thought it is only in Vista machine. Side by side error will come irrespective of OS, if reference assembly is missing from Sxs folder.
What is the Solution?
Now we need to think about the solution for this. Since the error message itself is saying “Please check windows event viewer for further information”. Go to event viewer and check for entry with sidebyside. Here we will take an example:
"Activation context generation failed for “DataViewer.dll". Dependent Assembly Microsoft.VC90.MFC, processorArchitecture="x86", publicKeyToken="1fc8b3b9a1e18e3b", type="win32", version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis."
Here we are clear with what we are missing. We are missing 9.0.21022.8 version of Microsoft.VC90.MFC. You can go to C:\Windows\WinSxs folder and manually verify this dependent assembly is there or not. Since we are missing an assembly, the only solution is that reference assembly should be in the machine we are running our application on. Since we need to install dependent assembly to our client machine, we need to run Microsoft redistributable package for the required assembly to client machine. See section website for patches for downloading packages.
Are Sxstrace.exe Tools Useful?
This tool helps us for detailed diagnosis such as assembly probing steps. It also help us to identify what all are the previous versions available and loaded by the application and which folder it is currently searching for.
How Can I Use sxstrace.exe?
For running sxstrace.exe, go to Visual Studio command prompt and type sxstrace.exe. Usage is as follows:
- Before running your application, run
sxstrace
in trace mode sxstrace.exe Trace -logfile:C:\tmp\MySxSTrace.log - Reproduce the error by starting your application
- Now stop the trace by using the below command sxstrace.exe Parse -logfile:C:\tmp\MySxSTrace.log -outfile:C:\tmp\MySxSTrace.txt
- Open output file from C:\tmp\MySxSTrace.txt
Website for Patches
- http://www.microsoft.com/downloads/details.aspx?familyid=2051A0C1-C9B5-4B0A-A8F5-770A549FD78C&displaylang=en#top (Visual Studio 2008)
- http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=766a6af7-ec73-40ff-b072-9112bab119c2 (Visual Studio 2005)
- http://www.microsoft.com/technet/security/bulletin/MS09-035.mspx
Conclusion
Side by side configuration error comes because of the referenced assembly missing from winsxs folder. There is no code change for this issue, we can install the required patches to client machine and rebooting the PC will resolve this issue.
History
- 11th November, 2009: Initial post
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
'Programming' 카테고리의 다른 글
[펌] What is a Manifest (in Windows)? (1) | 2011.04.26 |
---|---|
Manifests (from MSDN) (0) | 2011.04.26 |
[펌] SetThreadAffinityMask (0) | 2010.09.13 |