0

我正在使用 ironruby 执行一个脚本,该脚本加载一个具有依赖项的程序集,该依赖项需要在 app.config 中从 v2.0.0.0 重定向到 v3.5.0.0,如下所示:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="9.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
</runtime> 

该脚本适用于此重定向,但这需要我始终更改 ironruby app.config,它适用于所有脚本。我需要:

  • 为单个脚本定义此重定向
  • 在需要有问题的程序集之前执行注册重定向的代码

如何?

4

2 回答 2

1

您可以app.config通过使用我编写的名为configuration_settings_hackery.rb. 你可以在我的博客上阅读它。该博客文章包含指向 github 上的要点的链接。

我每天都使用这个 hack,并且我已经取得了很大的成功。您需要更改configuration_settings_hackery.rb文件的最后一行以指向您的app.config. 我发布的版本只是寻找c:\app.config.

于 2010-02-18T22:16:13.863 回答
0

我会尝试创建一个新AppDomainAppDomainSetup.ConfigurationFile设置为您的特殊文件app.config,然后在其中运行您的脚本AppDomain

于 2010-01-16T22:07:25.503 回答