0

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> 

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:

  • define this redirection either for a single script
  • execute code that registers the redirection before requiring the problematic assembly

How?

Bruno Lopes
  • 2,917
  • 1
  • 27
  • 38

2 Answers2

1

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.

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.

M. Scott Ford
  • 2,859
  • 1
  • 23
  • 24
  • Oh, this looks "nice". I'll try it during the weekend :) – Bruno Lopes Feb 19 '10 at 15:10
  • Okay, on further investigation I'm not sure this will work. While this works for configuration values, it doesn't for assembly binding. I think I may need to hook into the events .net fires for assembly resolving. – Bruno Lopes Feb 22 '10 at 13:07
0

I would try creating a new AppDomain with AppDomainSetup.ConfigurationFile set to your special app.config and then run your script in that AppDomain.

Lukas Cenovsky
  • 5,476
  • 2
  • 31
  • 39