WinSxS 无法加载 VC++ DLL

发布于 2025-01-02 08:02:56 字数 1551 浏览 0 评论 0原文

我遇到了几个 VC++ DLL 的问题,我应该将其包含到我的 .NET/C# 项目中。一个 VC++ DLL 是一个 C++/CLI DLL,我将其用作 .NET 项目的公共接口。其他 DLL 是用本机 C++ 编写的。我无法访问 VC++ DLL 的源代码,我只能使用它们。

我制作了一个 .NET 测试项目并引用了 C++/CLI DLL。没问题,编译器很幸运,太好了。只有一个问题:当我启动 .NET 程序的 EXE 时,由于缺少 VC++ 核心 DLL,我收到有关 C++ DLL 的错误。 sxstrace 显示以下内容(缩短):

INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Reference: Microsoft.VC80.OpenMP,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Resolving reference Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
...
ERROR: Cannot resolve reference Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".

现在我不是傻瓜,尝试了几件事。我阅读了很多有关 WinSxS 的内容,以便更深入地了解正在发生的事情。 现在我正处于一个让我感到奇怪的时刻。我要执行该程序的系统安装了当前版本8.0.50727.762 (SP1) 的VC++ Redistributable 软件包。我知道winsxs中有一个针对Microsoft.VC80.CRT的策略文件,该文件将该程序集的所有版本重定向到当前版本8.0.50727.762(这是问题的解决方案 http://blogs.msdn.com/b/nikolad/archive/2007/03/29/a-solution-to-two-references-to- Different-versions-of-crt-mfc-atl-in-one -application-manifest-file.aspx)。 但正如上面的错误所述,该策略文件似乎不起作用或未被考虑。系统只想找到8.0.50727.6195版本的程序集。

现在这是第一个问题:这里有什么问题?当我弄清楚这一点后,我可以解决最初的问题......

I've got a problem with several VC++ DLLs, which I should include into my .NET/C# project. One VC++ DLL is a C++/CLI DLL, which I use as public interface from my .NET project. The other DLLs are written in native C++. I have no access to the source of the VC++ DLLs, I just have to use them.

I've made a .NET test project and referenced the C++/CLI DLL. No problem, compiler is lucky, great. There's just one problem: when I start the EXE of the .NET program, I get errors about the C++ DLLs because of missing VC++ core DLLs.
sxstrace shows the following (shortened):

INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Reference: Microsoft.VC80.OpenMP,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Resolving reference Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
...
ERROR: Cannot resolve reference Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".

Now I'm no fool and tried several things. I've read much about WinSxS to get a deeper understanding about what's going on.
Now I'm at the point, where it's getting weired for me. The system where I want to execute the program has the VC++ Redistributable package in the current version 8.0.50727.762 (SP1) installed. I know that there's a policy file for Microsoft.VC80.CRT in winsxs that redirects all versions of this assembly to the current version 8.0.50727.762 (that's the solution for the problem at http://blogs.msdn.com/b/nikolad/archive/2007/03/29/a-solution-to-two-references-to-different-versions-of-crt-mfc-atl-in-one-application-manifest-file.aspx).
But as the error above says, this policy file doesn't seem to work or isn't taken into account. The system just wants to find the 8.0.50727.6195 version of the assembly.

Now that's the first question: what's the problem here? After I got this figured out, I could solve the initial problem...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴意少年 2025-01-09 08:02:56

好的,现在可以了 - 感谢您的帮助。

我发现了两个必须解决的问题:

1)我必须安装“Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update”,它部署了 VC++ 程序集的版本 8.0.50727.6195。在 Microsoft 服务器上很难找到此更新,因此链接如下:http ://www.microsoft.com/download/en/details.aspx?id=26347
通常您只能找到 8.0.50727.762 版本(“Visual C++ 2005 Service Pack 1 Redistributable Package”),该版本已过时。由于 C++ DLL 是针对 6195 编译的,因此安装更新解决了第一个问题。

2) 虽然 C++/CLI DLL是在发布模式下编译的,下面的本机 C++ DLL 已在调试模式下交付,现在 Microsoft 许可协议禁止部署该版本。 VC++ 调试 DLL 和 VC++ Redist 包不包含 VC++ 调试 DLL。
http://msdn.microsoft.com/en-us/library/aa985618.aspx 说:

应用程序的调试版本不可重新分发,并且各种 Visual C++ 动态链接库 (DLL) 的调试版本均不可重新分发。

解决方案:本机 C++ DLL 的开发人员给了我一个发行版本,一切正常......

Ok, now it works - thanks for your help.

I figured out two problems that had to be solved:

1) I had to install the "Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update", which deploys version 8.0.50727.6195 of the VC++ assemblies. This update was hard to find at the Microsoft servers, so here's the link: http://www.microsoft.com/download/en/details.aspx?id=26347
Normally you only find the 8.0.50727.762 version ("Visual C++ 2005 Service Pack 1 Redistributable Package), which is outdated. Since the C++ DLLs were compiled against 6195, installing the update solved the first problem.

2) While the C++/CLI DLL was compiled in Release mode, the native C++ DLLs below had been delivered in Debug mode. Now the Microsoft license agreement prohibits deploying the VC++ Debug DLLs and the VC++ Redist Packages don't include the VC++ Debug DLLs.
http://msdn.microsoft.com/en-us/library/aa985618.aspx says:

Debug versions of an application are not redistributable and none of the debug versions of the various Visual C++ dynamic-link libraries (DLLs) are redistributable.

Solution: the developers of the native C++ DLLs gave me a release version and everything works fine...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文