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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7508433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:07:46  来源:igfitidea点击:

Replacing Microsoft.VC90.CRT WinSxS policy file with local config file

windowsvisual-c++manifestconfigwinsxs

提问by arcamax

On Windows XP, I have an .exe which runs with msvcp90.dll, msvcr90.dll, and Microsoft.VC90.CRT.manifestin 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:

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

<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?

使用配置文件而不是策略文件时,Dependency Walker 报告并排错误 - 有什么问题?另外,应该将配置文件命名为<application>.exe.config,还是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 docsstate 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.)

MSDN文档状态的应用程序的配置文件可以重定向到使用不同版本的相同组件(应用每个应用的配置),并且如果需要的话它可以覆盖现有策略(出版商配置)文件。所以我认为必须可以使用本地应用程序配置文件,并且上面文件中的某些内容丢失或不正确。)

回答by Eugene Talagrand

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

您的配置数据位于<runtime>节点下。它应该在<windows>节点下。

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.

我必须警告说,非常不鼓励传送包含绑定重定向的应用程序配置文件,并且对于处理他们管理的机器上的 appcompat 问题的系统管理员来说,这是一种建议。应用程序开发人员应该编写他们的应用程序以使用他们所依赖的 CRT 的特定版本的最新版本,并使用该版本附带的默认全局策略。

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

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

回答by James

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.

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