[IronPython] IronPython code to call IronRuby fails; equivalent? C# code works

Dino Viehland dinov at microsoft.com
Sat Apr 17 00:11:49 CEST 2010

Is this IronPython 2.6.1 and IronRuby 1.0?

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of john.cawley at rkeng.com
Sent: Friday, April 16, 2010 2:20 PM
To: Users at lists.ironpython.com
Subject: [IronPython] IronPython code to call IronRuby fails; equivalent? C# code works

I'm at the beginning stages of calling IronRuby from IronPython, but am having difficulty creating the ruby engine.

This code works from C# in VS2008:

                // with referenced assemblies IronRuby, IronRuby.Libraries, IronRuby.Libraries.YAML, Microsoft.Scripting,
                //     Microsoft.Scripting.Core from the IronRuby bin\ directory
                var engine = IronRuby.Ruby.CreateEngine();
                String s = engine.ToString();
                MessageBox.Show( s, "test");
                // successfully returns "Microsoft.Scripting.Hosting.ScriptEngine"

Trying to do the identical logic with this IronPython code:

                import clr, sys
                clr.AddReferenceToFileAndPath( "C:/Apps/IronRuby/bin/IronRuby.dll" )   # after initially failed, tried adding specific path to IronRuby DLLs ...
                clr.AddReferenceToFileAndPath( "C:/Apps/IronRuby/bin/IronRuby.Libraries.dll" )
                clr.AddReferenceToFileAndPath( "C:/Apps/IronRuby/bin/IronRuby.Libraries.YAML.dll" )
                clr.AddReferenceToFileAndPath( "C:/Apps/IronRuby/bin/Microsoft.Scripting.dll" )
                clr.AddReferenceToFileAndPath( "C:/Apps/IronRuby/bin/Microsoft.Scripting.Core.dll" )
                import IronRuby

                for r in clr.References: print "ref", r   # to verify I have the correct assemblies loaded
                print ""

                print "fence 0"
                engine = IronRuby.Ruby.CreateEngine()   # fails here
                print "fence 1"

                print engine

This gives this output:

                ref mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
                ref System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
                ref IronRuby, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
                ref IronRuby.Libraries, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
                ref IronRuby.Libraries.Yaml, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
                ref Microsoft.Scripting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
                ref Microsoft.Scripting.Core, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35

                fence 0
                Traceback (most recent call last):
                StandardError: Failed to load language 'IronRuby': Could not load type 'Microsoft.Scripting.Interpreter.ILightCallSiteBinder' from assembly 'Microsoft.Dynamic, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

I also added a reference to IronRuby's version of the Microsoft.Dynamic.dll, but it still failed similarly. The logic I'm trying to execute is brief enough that there shouldn't be much that could go wrong, but ...

Thanks in advance for any insights!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100416/de22a451/attachment.html>

More information about the Ironpython-users mailing list