# Ironruby in VB.net and rubygems

**URL:** <https://www.ruby-forum.com/t/ironruby-in-vb-net-and-rubygems/216206>\
**Category:** IronRuby\
**Created:** [January 29, 2012, 9:30pm UTC](https://www.ruby-forum.com/t/ironruby-in-vb-net-and-rubygems/216206 "2012-01-29T21:30:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 29, 2012, 9:30pm UTC](https://www.ruby-forum.com/t/ironruby-in-vb-net-and-rubygems/216206/1 "2012-01-29T21:30:17Z")

</div>

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](http://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](http://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 1.1.3.0 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

---

<div class="post-metadata">

**Author:** ![Andreas\_Beck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Andreas\_Beck](https://www.ruby-forum.com/u/Andreas_Beck)\
**Post date:** [January 30, 2012, 12:23am UTC](https://www.ruby-forum.com/t/ironruby-in-vb-net-and-rubygems/216206/2 "2012-01-30T00:23:54Z")

</div>

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):

[http://code.google.com/p/efficientlylazycrypto/source/browse/trunk/ThirdParty/Gallio/DLR/libs/ir.exe.config?r=46](http://code.google.com/p/efficientlylazycrypto/source/browse/trunk/ThirdParty/Gallio/DLR/libs/ir.exe.config?r=46)

Orion
