使用本地配置文件替换 Microsoft.VC90.CRT WinSxS 策略文件

发布于 2024-12-06 01:02:57 字数 2320 浏览 3 评论 0原文

在 Windows XP 上,我有一个 .exe 与 msvcp90.dllmsvcr90.dllMicrosoft.VC90.CRT.manifest 一起运行我的本地应用程序目录。我在 C:\WINDOWS\WinSxS\Policies 中还有这些 .dll 的策略文件,它是由 Visual C++ 2008 SP1 可再发行组件包。我想删除此策略文件并使用本地目录中的应用程序配置文件。策略文件是:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity type="win32-policy" name="policy.9.0.Microsoft.VC90.CRT" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
            <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30729.1"/>
            <bindingRedirect oldVersion="9.0.30201.0-9.0.30729.1" newVersion="9.0.30729.1"/>
        </dependentAssembly>
    </dependency>
</assembly>

我的配置文件是:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
            <dependentAssembly>
                <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
                <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30729.1"/>
                <bindingRedirect oldVersion="9.0.30201.0-9.0.30729.1" newVersion="9.0.30729.1"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

使用配置文件而不是策略文件时,Dependency Walker 报告并行错误 - 出了什么问题?另外,配置文件应该命名为 .exe.config 还是 Microsoft.VC90.CRT.config

(澄清一下,使用策略文件时不会出现错误。但是,这里的客户端不允许安装可再发行组件包。

MSDN 文档 指出应用程序配置文件可以重定向应用程序以使用同一程序集的不同版本(每个应用程序配置),并且它可以如果需要,覆盖现有的策略(发布者配置)文件,因此我认为必须可以使用本地应用程序配置文件,并且上面的文件中的某些内容丢失或不正确。)

On Windows XP, I have an .exe which runs with msvcp90.dll, msvcr90.dll, and Microsoft.VC90.CRT.manifest in my local application directory. I also have a policy file for these .dlls in C:\WINDOWS\WinSxS\Policies, which was installed by the Visual C++ 2008 SP1 Redistributable Package. I'd like to delete this policy file and use an app config file in my local directory instead. The policy file is:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity type="win32-policy" name="policy.9.0.Microsoft.VC90.CRT" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
            <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30729.1"/>
            <bindingRedirect oldVersion="9.0.30201.0-9.0.30729.1" newVersion="9.0.30729.1"/>
        </dependentAssembly>
    </dependency>
</assembly>

My config file is:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
            <dependentAssembly>
                <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/>
                <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30729.1"/>
                <bindingRedirect oldVersion="9.0.30201.0-9.0.30729.1" newVersion="9.0.30729.1"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Dependency Walker reports side-by-side errors when using the config file instead of the policy file - what's wrong? Also, should the config file be named <application>.exe.config, or Microsoft.VC90.CRT.config?

(To clarify, no errors appear when using the policy file. However, the client here is not allowed to install the redistributable package.

The MSDN docs state that an app config file can redirect the application to use different versions of the same assembly (per-application configuration), and that it can override an existing policy (publisher configuration) file if needed. So I think it must be possible to use a local app config file, and that something in the file above is missing or incorrect.)

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

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

发布评论

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

评论(2

執念 2024-12-13 01:02:57

您的配置数据位于 节点下。它应该位于 节点下。

我必须警告的是,强烈建议不要传送包含绑定重定向的应用程序配置文件,这适用于处理其管理的计算机上的应用程序兼容性问题的系统管理员。应用程序开发人员应该编写他们的应用程序,以使用他们所依赖的 CRT 特定版本的最新版本,并使用该版本附带的默认全局策略。

事实上,从 Windows 2003 开始​​,在应用程序配置文件中使用绑定重定向需要应用程序兼容性数据库中的条目。

Your configuration data is under the <runtime> node. It should instead be under the <windows> node.

I have to caution that shipping application configuration files that contain binding redirects is highly discouraged and is inteded for system administrators dealing with an appcompat problem on the machines they adminster. Application developers should instead be authoring their applications to work with the latest revision of the specific version of the CRT they depend on and use the default global policy that ships with that version.

In fact, starting with Windows 2003, using binding redirects in an application configuration file requires an entry in the application compatibility database.

[浮城] 2024-12-13 01:02:57

据我了解,出于安全原因,c 运行时不能以这种方式重定向。您的选择是将运行时静态构建到项目中,或者从应用程序目录加载 DLL,而不使用并排系统。

It is my understanding that the c runtimes cannot be redirected in this way for security reasons. Your options are to statically build the runtimes into your project or load the DLLs from your application directory with out the Side-By-Side system.

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