Calling C# from IronRuby

c#, ironruby

Solution

The first thing to pay attention is that I'm not sure how IronRuby will handle namespaces that start with a lowercase letter. If I remember correctly, your namespace will simply be ignored, but i'm not sure about it. In the Ruby language, modules (which are the equivalent to C# namespaces) must start with a capital letter.

After you change the namespace to start with a capital letter - HelloWorldLib, you can use require or load_assembly to load your assembly.

require will load you assembly only once (even when the dll is required several times) and load_assembly will reload the assembly every time it is called.

This code will run your snippet:

require 'C:\Documents and Settings\myUser\My Documents\Visual Studio 2008\Projects\Project1\helloWorldLib\bin\Debug\helloWorldLib.dll'
greeter = HelloWorldLib::Greeter.new
greeter.say_hello_world "Michael"

Problem

I have created a small C# class in a library. ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace helloWorldLib { public class Greeter { public string SayHelloWorld(string name) { return "Hello world " + name; } } } ``` The library is located in C:\Documents and Settings\myUser\My Documents\Visual Studio 2008\Projects\Project1\helloWorldLib\bin\Debug\helloWorldLib.dll How would you call SayHelloWorld from an IronRuby script? I know this seems very simple, but I cannot seem to find a consistent code example after much research. Thanks so much!

Original source