[Ironruby-core] ironruby in VB.net and rubygems

Orion Edwards orion.edwards at gmail.com
Sun Jan 29 17:55:49 EST 2012

Not sure if this is your problem, but off the top of my head I'll try help.

IronRuby needs to know the path to it's standard library directory. This is stored in the ir.exe.config file that ships along with IronRuby. 
When you host IronRuby from inside another application, this config file isn't present. 
Rubygems isn't one of the core libraries (those are implemented in IronRuby.Libraries.dll), and so when you try and require rubygems, it goes looking for the standard library, and fails.

Try open ir.exe.config from the IronRuby directory, and copy the parts which reference file paths over to your own app.exe.config (and remember to update the paths, etc).

It should look kind of like this (NOTE: this is an old config file and so it won't be correct for the latest version of ir):



On 30/01/2012, at 9:29 AM, Andreas Beck wrote:

> Hi,
> I've just encountered the following problem:
> I've installed the gem "builder" in version 2.0 via igem and it works fine. When using it in a script first the first 2 lines are:
>     require 'rubygems'
>     require 'builder'
> In VB.net I execute ruby code in the following way:
> I linked:
>     IronRuby.dll
>     IronRuby.Libraries.dll
>     IronRuby.Lbraries.Yaml.dll
> from InstallationDirectory\Silverlight\bin\
> my code which works fine with "regular" ruby code:
>     Sub Main(ByVal Args As String())
>         Dim rubyRuntime As Microsoft.Scripting.Hosting.ScriptRuntime
>         Dim rubyEngine As Microsoft.Scripting.Hosting.ScriptEngine
>         rubyRuntime = IronRuby.Ruby.CreateRuntime
>         rubyEngine = rubyRuntime.GetEngine("rb")
>         Dim strRuby As String
>         Dim fileReader As StreamReader
>         fileReader = New StreamReader(System.Environment.CurrentDirectory & "\" & Args(0))
>         strRuby = fileReader.ReadToEnd
>         fileReader.Close()
>         fileReader = Nothing
>         rubyEngine.Execute(strRuby)
>     End Sub
> Now, when I compile the code the libraries I linked are copied in my output directory as usual. And here the problem starts. When this library IronRuby.Libraries.dll is in the directory where my programm is running, executing the "require 'rubygems'" throws an error. It's the same when I start ir on the command line and type it in. When I delete this library the ruby code runs without any problem, but the VB.net program won't execute any more. Here's the error message:
>     C:/Program Files/IronRuby 1.1/Lib/ironruby/thread.rb:16:in `load_assembly': Specified type IronRuby.StandardLibrary.Threading.ThreadingLibraryInitializer is not a subclass of IronRuby.Builtins.LibraryInitializer (LoadError)
>     from C:/Program Files/IronRuby 1.1/Lib/ironruby/thread.rb:16
>     from C:/Program Files/IronRuby 1.1/Lib/ruby/1.9.1/rubygems.rb:16:in `require'
>     from C:/Program Files/IronRuby 1.1/Lib/ruby/1.9.1/rubygems.rb:16
>     from (ir):1:in `require'
>     from (ir):1
> The versions I use:
> IronRuby on .NET 4.0.30319.239
> MS Visual Studio 2010
> I desperately hope for help as I couldn't any helping post in the archives!
> thanks in advance
> Andreas
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core

More information about the Ironruby-core mailing list