Most of the developers, using assemblies in there application may 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 file are installed in single machine.
并排配置是一个版本控制的把戏,目的是让一个文件的多个版本能安装在同一台机器上。
This is achieved through manifest files.
这通过manifest来归档。
Eg: the C Runtime Library assembly contains three DLLs—msvcr80. dll, ,msvcm80.dll and msvcp80.dll
例如:C运行时库集合包含三个DLLs,
and is used by applications when they are built using functions from the CRT library.
当他们在build过程中使用CRT库中的函数时,dll将会被用在程序中。
Side-by-side technology is also known as WinSxS or SxS.
并排的技术也称为WinSxS或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.
并排程序集包含一个资源集合--一组dll,windows classes, COM serversz,库类型,或各种接口。通常将他们打包后交给application。
These are described in the assembly manifest.
以上工作都在程序集manifest中体现出来。
Why it is important?
为什么它是重要的?
In many cases it is possible to update existing applications to use side-by-side assemblies without having to change the application code.
因为这使我们能够使用并排程序集更新现有的application而不是通过修改源程序的代码。
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:
开发人员被鼓励使用程序集来创建独立的应用程序,并且更新已经存在的应用程序到独立的application是因为以下原因:
•Side-by-side assemblies reduce the possibility of DLL version conflicts.
•并排程序集能减少了DLL版本冲突的可能性。
•Side-by-side assembly sharing enables multiple versions of COM or Windows assemblies to run at the same time.
•并排程序集共享机制使COM的多个版本或windows程序集能在同一时刻运行。
•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 it is 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.
在前面的示例中所示上图6.0版本的Comctl32.dll和5.0版本的Comctl32.dll都在并排程序集缓存中,并且对application都是可用的。
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.
当一个应用程序调用来加载DLL时,并排管理器根据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 。
对于Windows XP,5.0版本的Comctl32.dll是系统默认值。
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 。
如果并排管理器在manifest声明中发现一个对6.0版本程序的依赖项,则系统将会为这个应用程序加载6.0版本的dll。
Is it related Project settings?
这是相关的项目设置吗?
We have to check is it possible to resolve with project settings because exe will run in debug build and is failing to start in release build.
我们必须检查是否有可能通过项目设置来解决问题,因为exe将会在调试版本中build,但是在发布版本中build时将会失败。
Change your project settings to not use the runtime library, but this will make the output exe bigger.
通过不使用运行时库来改变你的项目设置,这将会使exe的输出非常大。
(Project Properties -> C/C++ -> Code Generation -> Runtime Library -> use/MT or /MTd depends on your current configuration)
(项目属性- > C / C + + - >代码生成- >运行时库- >使用/太或/ MTd取决于你当前的配置)
This may work, but it is not the solution for this issue.
这可以工作,但它不是解决问题的办法。
Is it OS related?
它是操作系统相关吗?
No, it is not OS related issue.
不,它不是操作系统相关的问题。
Since most of the experience for this issue is in vista, initially I thought it is only in vista machine.
因为对于这个问题,大部分的经验是在vista,起初我以为只有在vista机器。
Side by side error will come irrespective of OS, if reference assembly is missing from Sxs folder.
如果Sxs文件夹中的参考程序集丢失了,并排程序集与操作系统无关。
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”.
因为这个错误消息本身是说“请检查windows事件查看器进行进一步的信息”。
Go to event viewer and check for entry with sidebyside.
因而,我们去事件查看器和检查与sidebyside有关系的条目。
Here we will take and 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."
“激活上下文生成失败的“dataviewer dll”。程序依赖集 microsoft.vc90,MFC,处理器架构为X86,版本号为9.0.21022.8。公钥为1fc8b3b9a1e18e3b类型为win32,不能找到。请用sxstrace.exe详细诊断。”
Here we are clear with what we are missing.
我们怎样搞清楚我们缺少的东西呢
We are missing 9.0.21022.8 version of Microsoft.VC90.MFC.
我们丢失的是版本号为9.0.21022.8的Microsoft.VC90.MFC
You can go to C:/Windows/WinSxs folder and manually verify this dependent assembly is there or not.
你可以去C:/ Windows / WinSxs文件夹并手动验证这个依赖集到底有还是没有。
Since we are missing assembly, the only solution is that reference assembly should be in machine we are running our application.
因为我们缺少该程序集,唯一的解决办法是让参考程序集在运行我们的应用程序的机器上。
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.
因为我们要安装程序集到我们客户端机器上,所以我们需要运行Microsoft redistributable package来将需要的程序集安装在我们的客户机器上。
See section website for patches for downloading packages.
看到下载的补丁包网址区。
Is Sxstrace.exe tools is useful?
是Sxstrace.exe工具是有用的吗?
This tool helps us for detailed diagnosis such as assembly probing steps.
这个工具帮助我们探测步骤详细诊断这样的程序集。
Also help us to identify what all are the previous version available and loaded by the application and which folder it is currently searching for.
也帮助我们识别那些先前可用的版本和当前正在查找的文件版本。
How can I use sxstrace.exe?
我如何使用sxstrace.exe吗?
For running sxstrace.exe go to visual studio command prompt and type sxstrace.exe.
你应该打开visual studio command prompt,然后键入sxstrace.exe
Usage is as follows:
Usage is as follows:
用法如下:
sxstrace.exe Trace -logfile:C:/tmp/MySxSTrace.log
通过启动程序让错误重现。
用以下命令来停止跟踪
sxstrace.exe Parse -logfile:C:/tmp/MySxSTrace.log -outfile:C:/tmp/MySxSTrace.txt
Website for patches
网站补丁
http://www.microsoft.com/technet/security/bulletin/MS09-035.mspx
Conclusion
结论
Side by side configuration error is coming because of the referenced assembly missing from winsxs folder.
,因为参考程序集从winsxs文件夹中失踪,因而并排配置错误来了。
There is no code change for this issue, we can install required patches to client machine and reboot the PC will resolve this issue.
没有代码变更,这个问题,我们可以在客户端机器安装所需补丁,重启电脑后这个问题将会被解决。