【问题标题】:configure assemblyBinding once for multiple executables为多个可执行文件配置一次 assemblyBinding
【发布时间】:2010-12-08 10:24:57
【问题描述】:

我有一个包含多个可执行文件的文件夹。目前,程序集绑定重定向在每个 executable.exe.config 文件中配置。有没有办法只配置一次,该文件夹中的所有可执行文件都会自动选择它?我想避免 machine.config 因为这会将它应用于整个计算机。

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <publisherPolicy apply="yes" />
  <dependentAssembly>
    <assemblyIdentity name="SomeAssembly" publicKeyToken="10addddbec4aebba" />
    <publisherPolicy apply="yes" />
      <bindingRedirect oldVersion="0.0.0.0-7.9.999.0" newVersion="5.8.11.5" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="SomeOtherAssembly" publicKeyToken="23adeddbac4ae12a" />
    <publisherPolicy apply="yes" />
      <bindingRedirect oldVersion="0.0.0.0-7.9.999.0" newVersion="5.8.11.5" />
  </dependentAssembly>
</assemblyBinding>

【问题讨论】:

    标签: .net clr assembly-resolution fusion assemblybinding


    【解决方案1】:

    可以将您的配置“拆分”到不同的部分,并将这些部分放置到外部文件中。您将为每个 exe 提供一个几乎空的配置,并在其中添加这样的部分。然而Enterprise Lib为此提供了一个应用程序块。
    另一种解决方案是使用符号文件链接 - 又名 junction - 将每个配置重定向到全局配置(但我不建议这样做)。

    【讨论】:

      【解决方案2】:

      我相信没有办法为多个可执行文件创建一个配置文件。 MSDN 仅提及两个选项 - executable.exe.config 和全局 machine.config

      我想到的唯一解决方案是创建一个具有所有当前可执行文件功能(和一个通用配置)的大型可执行文件,然后通过某种开关等使您当前的可执行文件运行大型可执行文件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-12-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多