WinSxS:如何依赖特定版本的gdiplus.dll?

发布于 2024-08-04 02:42:26 字数 1003 浏览 5 评论 0原文

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

替代文字

我想确保我使用此版本是出于特定的兼容性原因。

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

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

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

替代文字

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

所以问题是:如何获取对特定版本的 Windows dll 的依赖关系?

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

alt text

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

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>

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:

alt text

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

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

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

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

发布评论

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

评论(1

妖妓 2024-08-11 02:42:26

您的“问题”是安装了一个策略文件,该文件指定可以将 5.1.3102.2180 的请求重定向到 5.02.6002.18005

这通常是一件好事。它允许应用程序在清单中指定其构建版本,但是当引入关键安全修复程序时,操作系统可以将应用程序重定向到兼容版本。

因此,这里将发生的情况是,您的应用程序将在任何仅安装了 5.1 的 PC 上链接到 GDI+ 5.1。但任何配备 5.2 GDI+ 的 PC,您都会被重定向到该位置。

如果您确实有一个诚实的理由为什么要使用 5.1,即使 5.2 可用......我认为您可以使用应用程序配置文件来管理它。

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

但我不确定如何构造 bindingRedirect。即给定策略文件重定向,我不确定您是否需要将旧版本重定向回其本身,或将新版本重定向回旧版本。或者什么。可能需要一些尝试和错误。

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

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

为了使“oldVersion”的选择更容易,它支持范围语法。这将

oldVersion="5.0.0.0-5.3.0.0"

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

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.

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.

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.

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

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.

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"/>

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

oldVersion="5.0.0.0-5.3.0.0"

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

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