【问题标题】:Howto: Multiple versions of msvcrt9 as private SxS assemblies?如何:多个版本的 msvcrt 9 作为私有 SxS 程序集?
【发布时间】:2010-11-07 16:26:03
【问题描述】:

我有一个项目,其中包含预构建的 Dll 模块,它是在过去一段时间使用 Visual Studio 9 构建的。

项目的 EXE 现已构建,使用 Visual Studio 9 的 SP1。

当我们部署 EXE 时,我们不希望需要管理访问权限,因此 C-Runtime 已捆绑到应用程序的根目录中。 Dll:MSVCRT90.DLL 及其清单:Microsoft.VC90.CRT.manifest

现在,EXE 和最新版本的运行时清单都一致了 - 应用程序清单要求 msvcrt.dll 的 9.0.30729.1,crt-manifest 包含确认 msvcrt90.dll 版本为 9.0.30729.1 的条目

现在,一个问题。我们的应用程序使用的第 3 方 DLL 库与原始 msvcrt90.dll 版本 9.0.21022.8 相关联,并且具有此效果的内部清单。

在安装了两个版本的 VS9 CRuntime 的开发 PC 上,该应用程序可以正常工作。在我们首次安装应用程序的“新”PC 上 - DLL 无法加载。

现在,我可以做一些作弊 - 一个是将应用程序恢复到 9.0.2 - 从原始源媒体中获取 9.0.2 DLL。这是不可取的,因为 9.0.3 更可取。 或者我非常努力地重建 3rd 方库。

我还非常确定,在我们的开发 PC 上,当第 3 方库请求旧 dll 时,它会被重定向到新 dll - 它们是二进制兼容的。

应用程序清单和程序集旨在将我们所有人从这种垃圾中拯救出来。 必须可以编辑程序集清单文件,以便 exe 和 dll 都可以加载。

【问题讨论】:

    标签: windows unmanaged side-by-side


    【解决方案1】:

    我从未尝试过,但我认为您可以通过清单中的 bindingRedirect 来解决这个问题,我知道它在托管世界中有效。

    查看示例(您需要更改版本的值)

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <configuration>
      <windows>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <assemblyIdentity name="Your.Application.Name" type="win32" version="9.0.0.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.30411.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC90.MFC" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" />
            <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30411.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC90.MFCLOC" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b">
            </assemblyIdentity>
            <bindingRedirect oldVersion="9.0.20718.0-9.0.21022.8" newVersion="9.0.30411.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </windows>
    </configuration>
    

    【讨论】:

    • 这与我一直在尝试的非常接近。但是,我在哪里以及如何放置该 XML?我的应用程序有一个嵌入的 .manifest 文件,文档说 bindingRedirections 应该放在 app.exe.config 文件中。我已经创建了配置文件,将其放在我的应用程序文件夹中,没有发现任何区别。我不确定它是否被使用。也许我需要确保 assemblyIdentity 与我的应用程序清单 assemblyIdentity 完全匹配。
    • 它需要在manifest里面,你可以在VS生成的manifest中添加你自己的声明,我这里没有VS所以我不能给你确切的方法,但是它在某个地方在项目设置\manfirst 工具下
    • 只是一些澄清:如果 EXE 具有必须重定向的依赖程序集,则本地策略文件的适当名称是:application.exe.config - 如果它是具有依赖关系的卫星 dll需要重定向的程序集,然后策略文件称为 dllname.dll.2.config - 为什么是 .2 ?我不知道。但它必须在那里。
    猜你喜欢
    • 2010-10-12
    • 2017-12-17
    • 2010-09-05
    • 2013-11-27
    • 1970-01-01
    • 2013-10-26
    • 2019-06-11
    • 1970-01-01
    • 2011-05-25
    相关资源
    最近更新 更多