开发者

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

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>
           开发者_如何学C     <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.)


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜