我正在编译一个使用多个DLL并使用VS2008编译的项目。最近的 Windows 更新后,在我的计算机上编译的 DLL 在其他计算机上停止工作。
经过一番调查后发现,它将我正在编译的 CRT 可再发行库从版本“9.0.21022.8”更新为版本“9.0.30729.4148”,
这从我正在编译的 EXE 的清单文件中可以明显看出。它包含以下内容:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
意味着它想要同时使用两个不同版本的 CRT。
我现在正在编译的代码需要第二个版本,而几周前编译的旧 dll 需要第一个版本。
在部署应用程序的计算机中,这会成为一个问题,因为它们从名为 Microsoft.VC90.CRT
的本地文件夹而不是从 WinSXS 获取 CRT dll。
此文件夹不能包含两个不同版本的 dll。
此问题是否有已知的解决方案,或者我是否需要开始使用新的 CRT 编译所有其他 DLL?
I'm compiling a project which uses multiple DLL and compiles with VS2008. After a recent windows update DLLs compiled on my computer stopped working on other computers.
After some investigation it turned out that it updated the CRT redistributable library which I'm compiling with from version "9.0.21022.8" to version "9.0.30729.4148"
This is evident from the Manifest file of the EXE i'm compiling. it contains the following:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
Meaning it wants to use two different versions of the CRT at the same time.
the second version is needed by the code which I'm compiling right now and the first version is needed by older dlls which were compiled a few weeks ago.
In the computers where the application is deployed this becomes a problem since they get their CRT dll from a local folder called Microsoft.VC90.CRT
and not from WinSXS.
This folder can't contain two different versions of the dll.
Is there a known solution to this issue or do I need to start compiling all of the other DLLs with the new CRT?
发布评论
评论(1)
这是并排装配引起的众多令人头痛的问题之一。每当 Visual Studio 有更新时,您确实需要重新编译所有代码。由于 CRT 中存在版本更改,因此某些代码使用一个 DLL,而其余代码则使用另一个。
另外,在分发时,您确实需要通过合并模块或 适当的安装集,而不是将 DLL 复制到应用程序文件夹中。这将允许程序通过 WinSxS 查找适当的运行时。
最后,如果您想完全解决问题,就像我一样,您可以将所有项目修改为 与 CRT 静态链接 并重新编译所有内容。这将完全消除对运行时 DLL 的依赖 - 至少是使用您自己的代码。这里不再需要担心 WinSxS。
This is one of the many headaches caused by Side-by-Side Assemblies. Any time there is an update for Visual Studio, you really need to recompile all your code. Because there was a version change in the CRT, some of your code is using one DLL and the rest is using another.
Also, when distributing, you really need to distribute the CRT through merge modules or the appropriate installation set instead of copying the DLL's into the application folder. This will allow the program to look up the appropriate runtime(s) through WinSxS.
Finally, if you want to remove the problem altogether, like I did, you can modify all your projects to link statically with the CRT and recompile everything. This will completely remove the dependency on the runtime DLL - at least, with your own code. No more WinSxS to worry about here.