[Ironruby-core] InternalsVisibleTo

Jimmy Schementi Jimmy.Schementi at microsoft.com
Wed Jan 20 03:46:44 EST 2010

> The call to assign the results of Parse to P always fails unless I 
> a) Do what Ivan suggested and copy to the bin folder
> b.) Modify ir.exe.config to include the path to the actual .dll

I would suggest neither of these =P See below.

> I was reading the source code this evening and noticed that during
> the RubyContext buildup it only includes the following paths to 
> resolve references:
> context.Loader.GetLoadPathStrings()
> {string[4]}
>    [0]: "F:/ironruby-ironruby-178b744/Merlin/Main/Languages/Ruby/libs/"
>    [1]: "F:/ironruby-ironruby-178b744/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/"
>    [2]: "F:/ironruby-ironruby-178b744/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/"
>    [3]: "."
> I assumed this is was why if I dump my .dll into any of those paths it resolves.

Resolving DLLs should behave the same way as resolving Ruby libraries; it has to be on the load path. As you saw in the debugger, the load path is preset with the LibraryPaths value that is in the config, but it's preferred to modify the load path by appending string to the $LOAD_PATH (or $: shorthand) variable, rather than modifying the config file.

Consider the following directory structure:

Where foo.dll was compiled from this C# code:

  public class Foo {
    public static void Bar() {
      System.Console.WriteLine("In Bar");

If foo.rb just looked like this:

  require 'foo.dll'

... and ir.exe is anywhere but the dlls directory you'd get this error:

  PS C:\temp> ir .\bar.rb
  :0:in `require': no such file to load -- foo (LoadError)
          from ./bar.rb:1

However, if you add "dlls" to the load path first:

  $LOAD_PATH << File.dirname(__FILE__) + "/dlls"
  require 'foo.dll'

Then all will work:

  PS C:\temp> ir .\bar.rb
  In Bar

Notice that the first line "File.dirname(__FILE__)" to make the "dlls" path relative to the current file. Then doing "require 'foo'" will look in the dlls directory.

Does that solve your problem?


More information about the Ironruby-core mailing list