WinSxS:如何依赖gdiplus.dll的特定版本? [英] WinSxS: How to take dependency on specific version of gdiplus.dll?

查看:183
本文介绍了WinSxS:如何依赖gdiplus.dll的特定版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加对特定版本的GDIPlus的依赖.这是我想要的GDI +版本:

I need to add a dependency on a specific version of GDIPlus. This is the version of GDI+ that i want:

出于特定的兼容性原因,我想确保使用的是该版本.

I want to be sure that I'm using this version for a specific compatibility reason.

我已将程序集清单添加到可执行文件中,从而定义了对 GdiPlus 版本的依赖:

I've added an assembly manifest to my executable, defining my dependancy on the version of GdiPlus:

<dependency>
   <dependentAssembly>
      <assemblyIdentity 
            type="win32" name="Microsoft.Windows.GdiPlus" 
            pubicKeyToken="6595b64144ccf1df" 
            version="5.1.3102.2180" processorArchitecture="x86"
            language="*" />
   </dependentAssembly>
</dependency>

除了运行我的应用程序外,Windows的融合加载器从Side-by-Side文件夹中为我提供了gdiplus.dll的其他版本,我可以在Process Explorer中看到它:

Except when I run my application, Windows' fusion loader gives me some other version of gdiplus.dll from the Side-by-Side folder, which I can see in Process Explorer:

它给我的版本是 5.02.6002.18005 ,而不是 5.1.3102.2180 .

It's giving me version 5.02.6002.18005, rather than 5.1.3102.2180.

所以问题是:我如何依赖Windows dll的特定版本?

So the question is: How do I take a dependency on a specific version of a Windows dll?

推荐答案

您的问题"是这样的,即安装了一个策略文件,该文件指定对5.1.3102.2180的请求可以重定向到5.02.6002.18005

Your "problem", such that it is, is that there is a policy file installed that specifies that requests for 5.1.3102.2180 can be redirected to 5.02.6002.18005

通常,这是一件好事.它允许应用程序在其清单中指定针对其构建的版本,但是在引入了重要的安全修复程序之后,操作系统可以将应用程序重定向到兼容版本.

This is, usually, a good thing. it lets applications specify the version they were built against in their manifest, but when critical security fixes are introduced, the OS can redirect apps to compatible versions.

因此,这里要发生的是,您的应用程序将与仅安装5.1的任何PC上的GDI + 5.1链接.但任何装有5.2 GDI +的PC都将被重定向到该PC.

So, whats going to happen here is, your app is going to link against GDI+ 5.1 on any PC that has only 5.1 installed. but any PCs with the 5.2 GDI+, you will be redirected to that.

如果您确实有一个诚实的理由,即使在5.2可用的情况下,也要使用5.1.我想您可以使用应用程序配置文件来管理它.

If you do have an honest to goodness reason why you want to use 5.1, even when 5.2 is available... I think you can use an application config file to manage that.

创建一个名为yourapp.exe.config的文件-如果应用程序中导入GDI +的模块是dll,那么它将是thedll.dll.2.config

Create a file called, yourapp.exe.config - if the module in your app thats importing GDI+ is a dll, then it would be thedll.dll.2.config

但是我不确定如何构造bindingRedirect.即,给定策略文件重定向后,我不确定是否需要将旧版本重定向回自身,或将新版本重定向回旧版本.要不然是啥.可能需要反复试验.

I am unsure how to structure the bindingRedirect however. i.e. given the policy files redirection, im not sure if you need to redirect the old version back to itself, or the new version back to the old version. or what. some trial and error might be required.

.config文件中的数据看起来几乎与清单文件中的数据完全一样.像这样的东西(它几乎完全模仿了安装在winsxs中的策略文件的内容,即执行您不希望的重定向).

The data in the .config file looks almost exactly like the data in the manifest file. Something like this (which mimics almost exactly the contents of the policy file installed in winsxs thats doing the redirection you dont want).

<configuration>
  <windows>
    <assemblyBinding xmlns=...>
      <dependentAssembly name="GdiPlus...>
        <bindingRedirect oldVersion="5.1.x.x" newVersion="5.1.x.x"/>


为了简化"oldVersion"的选择,它支持范围语法.所以


To make the choice of "oldVersion" easier, it supports a range syntax. so

oldVersion="5.0.0.0-5.3.0.0"

将是确保整个GdiPlus版本都重定向到特定版本的简单方法.

would be a simple way to ensure that a whole range of GdiPlus versions get redirected to a specific version.

这篇关于WinSxS:如何依赖gdiplus.dll的特定版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆