2

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

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

当我们部署 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 更可取。或者我非常努力地重建第 3 方库。

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

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

4

1 回答 1

2

我从未尝试过,但我认为您可以在清单中使用 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>
于 2009-07-02T16:36:59.907 回答