在code,而不是大会的app.config重定向 [英] Assembly redirection in code instead of app.config

查看:126
本文介绍了在code,而不是大会的app.config重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用IronRuby的执行加载程序集与需要从V2.0.0.0重定向到v3.5.0.0像这样在app.config依赖的脚本:

I'm using ironruby to execute a script that loads an assembly with a dependency that needs to be redirected from v2.0.0.0 to v3.5.0.0 in the app.config like this:

<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中,它适用于所有的脚本。 我需要:

The script works with this redirection, but this requires me to always change the ironruby app.config, and it applies to all scripts. I need to either:

  • 定义此重定向无论是对一个脚本
  • 执行code是注册重定向要求有问题的装配前

如何?

推荐答案

您可以通过避免使用,我写所谓的黑客改变了IronRuby 的app.config configuration_settings_hackery.rb 。您可以读到它的在我的博客。该博客帖子包含一个链接到GitHub上一个要点。

You can avoid changing the IronRuby app.config by using a hack that I wrote called configuration_settings_hackery.rb. You can read about it on my blog. The blog post contains a link to a gist on github.

我使用这个技巧的每一天,我一直有很多与它的成功。您将需要更改 configuration_settings_hackery.rb 文件的最后一行指向的位置,你的的app.config 。我发布的版本只是看起来对 C:\的app.config

I use this hack every day, and I have been having a lot of success with it. You will need to change the last line of the configuration_settings_hackery.rb file to point to the location of your app.config. The version that I posted just looks for c:\app.config.

这篇关于在code,而不是大会的app.config重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆