The problem is probably caused by assembly load (IronRuby/DLR assemblies are 
loaded in a different context).

To fix this you can install IronPython and IronRuby to GAC. Using gacutil tool 
(http://msdn.microsoft.com/en-us/library/ex0ss12c(VS.80).aspx) from elevated 
command line

gacutil /i IronPython.dll
gacutil /i IronPython.Modules.dll
gacutil /i IronRuby.dll
gacutil /i IronRuby.Libraries.dll
gacutil /i IronRuby.Libraries.YAML.dll
gacutil /i Microsoft.Dynamic.dll
gacutil /i Microsoft.Scripting.Debugging.dll
gacutil /i Microsoft.Scripting.dll

Then you can use
clr.AddReference("IronRuby")

Tomas

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Friday, April 16, 2010 3:12 PM
To: Discussion of IronPython
Subject: Re: [IronPython] IronPython code to call IronRuby fails; equivalent? 
C# code works

Is this IronPython 2.6.1 and IronRuby 1.0?

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of john.caw...@rkeng.com
Sent: Friday, April 16, 2010 2:20 PM
To: Users@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=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089
                ref System, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089
                ref IronRuby, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35
                ref IronRuby.Libraries, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35
                ref IronRuby.Libraries.Yaml, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35
                ref Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35
                ref Microsoft.Scripting.Core, Version=1.0.0.0, 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=1.0.0.0, 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!
--John
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to