Re: Returning a CLR type from IronRuby

Paul Cowan <[email protected]> Tue, 3 Mar 2009 14:14:33 +0000
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <[email protected]>
I was talking about this IronRuby group:

http://groups.google.co.uk/group/ironruby?hl=en

It has very little traffic and I am guessing there is a better one?

I have removed the require from the .rb file and my code is below but the
same error persists:

[Fact]
public void Then_a_build_metadata_object_is_returned()
{
   var engine = Ruby.CreateEngine();
   engine.Runtime.LoadAssembly(typeof (Horn.Core.DSL.Domain.BuildMetaData
).Assembly);
   engine.ExecuteFile(buildFile);
   var klass = engine.Runtime.Globals.GetVariable("MetaDataFactory");
   var instance = (RubyObject)engine.Operations.CreateInstance(klass);
   var metaData = (BuildMetaData)engine.Operations.InvokeMember(instance,
"return_meta_data");
   Assert.Equal(metaData.Description, "A description of sorts");
}




2009/3/3 Curt Hagenlocher <[email protected]>

> On Tue, Mar 3, 2009 at 4:10 AM, Paul Cowan <[email protected]> wrote:
> > It is definitely the right assembly and I did post the question on
> IronRuby
> > but have not got an answer yet.
>
> I don't recall having seen this on the IronRuby list (at least not
> recently).
>
> > 2009/3/3 Fabian Schmied <[email protected]>
> >
> > While you'd probably get better answers at a Ruby-specific site, I'll
> > give it a try: The problem seems to be that IronRuby loads the
> > Horn.Core.DSL.Domain.dll assembly for a second time (and from a
> > different location), so the BuildMetaData type used by your IronRuby
> > class is not the same as the one used by the C# class.
> >
> > Can you try to do the following:
> > engine.Runtime.LoadAssembly (typeof (BuildMetaData).Assembly); // or
> > similar at the beginning?
>
> This should resolve the problem, but you also need to remove the
> "require" from the Ruby script.
>
> --
> Curt Hagenlocher
> [email protected]
>
> ===================================
> View archives and manage your subscription(s) at
> http://peach.ease.lsoft.com/archives
>

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives