Forum: IronRuby Ruby Instance of C# Class Isn't Really the C# Class

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2a743950e3ab15ca9868a2b7350112ab?d=identicon&s=25 Ashiq A. (Guest)
on 2013-09-13 20:59
(Received via mailing list)

I have a class defined in C# which I'm creating in Ruby and returning;
C# adds it to an array. It's simple (honest).

My setup is simple: the main project, and a class library called
"SharedClasses." Here's a class:

public class SimpleItem
        public string Name { get; set; }
        public int Value { get; set; }

        public SimpleItem(string name, int value)
            this.Name = name;
            this.Value = value;

Okay, nothing special here. Now, in Ruby, here's the script I want to

require 'SharedClasses.dll'
include SharedClasses"Red Gem", 100);

What I want to achieve, is to return the instance created back to C#,
add it to a List<SimpleItem>.

I can't do it. Currently, I get an InvalidOperationException: "can't
convert SharedClasses::SimpleItem into SharedClasses::SimpleItem"

Here's the code I use to create the Ruby instance:

var engine = Ruby.CreateEngine();
var newItem = engine.Execute<SimpleItem>(ruby);

I posted a Stack Overflow question for a more complex version of this
problem (this is the simplest case I could distill). Under other
circumstances, I can see that the two instances are the same, except
context (one is Default and one is LoadNeither).

Full post is here:

What am I doing wrong?


P.S. Visual Studio 2012 solution zip file, including IronRuby 1.13 via
NuGet, is available here:
415f258d946d25025cde6118a4e1aa6d?d=identicon&s=25 Brandon Doot (Guest)
on 2013-09-13 22:41
(Received via mailing list)
Hi Ashiq,

I remember running into something similar, I think I needed to use:

load_assembly 'SharedClasses.dll'
2a743950e3ab15ca9868a2b7350112ab?d=identicon&s=25 Ashiq A. (Guest)
on 2013-09-13 23:02
(Received via mailing list)
Hi Brandon,

Thanks, it works like a charm. I would love to know why, though :)

The working syntax was actually without the .dll extension:

If you're on Stack Overflow, feel free to reply to my answer (so you can
get the rep for it). If not, I will reply myself, so that it's forever


This topic is locked and can not be replied to.