[Ironruby-core] Consuming DynamicObjects in IronRuby

Tomas Matousek Tomas.Matousek at microsoft.com
Tue Mar 2 21:46:23 EST 2010


Jim, have we pushed sources out recently? It might be that we haven't since I made the change.

Tomas

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Robert Walker
Sent: Tuesday, March 02, 2010 6:30 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Consuming DynamicObjects in IronRuby

I've tried it with a fresh set of source, and building the "V4 Debug" target in VS2010.  Same behaviour, but more detail in the output window:

A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Dynamic.dll
MT_INIT: Exception
UPDATED: Exception                                          SetMethod: initialize          affected=1     rules=0
UPDATED: Exception                                          SetMethod: inspect             affected=1     rules=0
UPDATED: Exception                                          SetMethod: to_s                affected=1     rules=0
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Dynamic.dll
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Dynamic.dll

I'll see if I can come up with a more minimal repo case.

For what it's worth the call stack on the first exception is:

       Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.EnsureAvailableForClosure(System.Linq.Expressions.ParameterExpression expr = {System.Linq.Expressions.ParameterExpression}) Line 268       C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileGetVariable(System.Linq.Expressions.ParameterExpression variable = {System.Linq.Expressions.ParameterExpression}) Line 279 + 0x15 bytes   C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileParameterExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.ParameterExpression}) Line 340 + 0xf bytes C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.Compile(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.ParameterExpression}) Line 1378 + 0x15 bytes      C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileTypeEqualExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.TypeBinaryExpression}) Line 1272 + 0x30 bytes     C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.Compile(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.TypeBinaryExpression}) Line 1403 + 0x15 bytes     C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileLogicalBinaryExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.LogicalBinaryExpression}, bool andAlso = true) Line 683 + 0x3f bytes   C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileAndAlsoBinaryExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.LogicalBinaryExpression}) Line 659 + 0x12 bytes   C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.Compile(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.LogicalBinaryExpression}) Line 1343 + 0x15 bytes  C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileConditionalExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.ConditionalExpression}, bool asVoid = true) Line 697 + 0x33 bytes      C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.Compile(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.ConditionalExpression}) Line 1348 + 0x72 bytes    C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.ConditionalExpression}) Line 1327 + 0x15 bytes    C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.Block3}, bool asVoid = false) Line 356 + 0x58 bytes      C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.Compile(System.Linq.Expressions.Expression expr = {System.Linq.Expressions.Block3}) Line 1387 + 0x90 bytes      C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightCompiler.CompileTop(System.Linq.Expressions.LambdaExpression node = {System.Linq.Expressions.Expression<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>}) Line 195 + 0x32 bytes      C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Generation.CompilerHelpers.LightCompile(System.Linq.Expressions.LambdaExpression lambda = {System.Linq.Expressions.Expression<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>}, int compilationThreshold = 0xffffffff) Line 643 + 0x38 bytes  C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Utils.DynamicUtils.LightBind<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>(System.Dynamic.DynamicMetaObjectBinder binder = {IronRuby.Runtime.Calls.RubyCallAction}, System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>> site = {System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>}, object[] args = {object[0x00000002]}, int compilationThreshold = 0xffffffff) Line 67 + 0x76 bytes      C#
        IronRuby.dll!IronRuby.Runtime.Calls.RubyMetaBinder.BindDelegate<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>(System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>> site = {System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>}, object[] args = {object[0x00000002]}) Line 104 + 0xea bytes   C#
        System.Core.dll!System.Runtime.CompilerServices.CallSiteBinder.BindCore<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>(System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>> site, object[] args) + 0x55 bytes
        System.Core.dll!System.Dynamic.UpdateDelegates.UpdateAndExecute2<object,object,object>(System.Runtime.CompilerServices.CallSite site = {System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite,object,object,object>>}, object arg0 = {IronRuby.Runtime.RubyTopLevelScope}, object arg1 = {Medic.RapidResponse.Proxies.EREngineRecord}) + 0x3c0 bytes
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.DynamicInstruction<object,object,object>.Run(Microsoft.Scripting.Interpreter.InterpretedFrame frame = {Microsoft.Scripting.Interpreter.InterpretedFrame}) Line 163 + 0x17a bytes C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(Microsoft.Scripting.Interpreter.InterpretedFrame frame = {Microsoft.Scripting.Interpreter.InterpretedFrame}) Line 142 + 0x62 bytes C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.Interpreter.Run(Microsoft.Scripting.Interpreter.InterpretedFrame frame = {Microsoft.Scripting.Interpreter.InterpretedFrame}) Line 108 + 0xd bytes  C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Interpreter.LightLambda.Run2<IronRuby.Runtime.RubyScope,object,object>(IronRuby.Runtime.RubyScope arg0 = {IronRuby.Runtime.RubyTopLevelScope}, null arg1 = main) Line 97 + 0x24 bytes      C#
       IronRuby.dll!IronRuby.Runtime.RubyScriptCode.Run(Microsoft.Scripting.Runtime.Scope scope = {Microsoft.Scripting.Runtime.Scope}, bool bindGlobals = true) Line 111 + 0x5a bytes      C#
       IronRuby.dll!IronRuby.Runtime.RubyScriptCode.Run(Microsoft.Scripting.Runtime.Scope scope = {Microsoft.Scripting.Runtime.Scope}) Line 83 + 0x12 bytes     C#
        Microsoft.Scripting.dll!Microsoft.Scripting.Hosting.CompiledCode.Execute(Microsoft.Scripting.Hosting.ScriptScope scope = {Microsoft.Scripting.Hosting.ScriptScope}) Line 83 + 0x3e bytes    C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.SimpleCommandDispatcher.Execute(Microsoft.Scripting.Hosting.CompiledCode compiledCode = {Microsoft.Scripting.Hosting.CompiledCode}, Microsoft.Scripting.Hosting.ScriptScope scope = {Microsoft.Scripting.Hosting.ScriptScope}) Line 452 + 0x17 bytes     C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.ExecuteCommand(Microsoft.Scripting.Hosting.ScriptSource source = "(ir)") Line 343 + 0x47 bytes   C#
       IronRuby.dll!IronRuby.Hosting.RubyCommandLine.ExecuteCommand(string command = "r.StdUnitCost\n") Line 99 + 0x40 bytes C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.RunOneInteraction() Line 332 + 0x1f bytes    C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.TryInteractiveAction() Line 291 + 0x9 bytes   C#
       IronRuby.dll!IronRuby.Hosting.RubyCommandLine.TryInteractiveAction() Line 58 + 0xc bytes C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.RunInteractiveLoop() Line 236 + 0x18 bytes    C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.RunInteractive() Line 209 + 0xa bytes  C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.Run() Line 146 + 0x19 bytes C#
       IronRuby.dll!IronRuby.Hosting.RubyCommandLine.Run() Line 81 + 0xd bytes    C#
        Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.CommandLine.Run(Microsoft.Scripting.Hosting.ScriptEngine engine = "IronRuby", Microsoft.Scripting.Hosting.Shell.IConsole console = {Microsoft.Scripting.Hosting.Shell.BasicConsole}, Microsoft.Scripting.Hosting.Shell.ConsoleOptions options = {IronRuby.Hosting.RubyConsoleOptions}) Line 112 + 0x1a bytes       C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.ConsoleHost.RunCommandLine() Line 398 + 0x51 bytes  C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.ConsoleHost.ExecuteInternal() Line 332 + 0x1a bytes    C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.ConsoleHost.Execute() Line 308 + 0x1a bytes       C#
       Microsoft.Dynamic.dll!Microsoft.Scripting.Hosting.Shell.ConsoleHost.Run(string[] args = {string[0x00000000]}) Line 222 + 0xc bytes      C#
       ir.exe!RubyConsoleHost.Main(string[] args = {string[0x00000000]}) Line 60 + 0x3e bytes   C#


From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek
Sent: Tuesday, March 02, 2010 6:00 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Consuming DynamicObjects in IronRuby

It is a bug in DynamicObject for which I implemented a workaround in IronRuby some time ago. So the build from latest sources should help.

Tomas

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jim Deville
Sent: Tuesday, March 02, 2010 2:05 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Consuming DynamicObjects in IronRuby

Have you tried building Ruby directly? Get the sources from Github, then, from the command line, run
c:\path\to\merlin\main\languages\ruby\scripts\dev.bat
rb
devenv ruby4.sln

Inside of VS build ruby4.sln then:

1)      For basic testing, rbd will open a prompt for you to resume testing.

2)      For using it then without the sources, rake package will generate the release layout at c:\ironruby, which you can then copy to your desired location.

After 1.0, I'm going to look into making nightly drops available, but that's a little ways off.

If this still doesn't work, it might be a bug :(

JD

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Robert Walker
Sent: Tuesday, March 02, 2010 1:22 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Consuming DynamicObjects in IronRuby

(All work done with VS2010 RC and matching IronRuby build (v0.9.40, 07-Feb-10)).

I have a C# assembly that implements a dynamic object. When I try to use this object from Ruby I get the error:

>>> r.StdUnitCost
System.Core:0:in `BindCore': unbound variable: Param_0 (TypeError)
        from (ir):1

This usage works fine from a test C# 4.0 app using the 'dynamic' keyword.

I suspect that the issue is related to the version of the DLR in use -- there are a number of 'InvalidOperationExceptions' being thrown from the Microsoft.Dynamic.dll and I believe this is no longer a shipping assembly with .NET 4?

Is there a (simple) work around for this?

Thanks,

Rob Walker
Senior Software Architect
[cid:image001.gif at 01CAB992.6A7F4590]<http://www.kinaxis.com/>
http://www.kinaxis.com
Kinaxis
700 Silver Seven Road
Ottawa, ON, Canada K2V 1C3
Office:

+1 613.592.5780 ext. 5282

Fax:

+1 613.592.0584


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100303/7a59b4bb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 1706 bytes
Desc: image001.gif
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100303/7a59b4bb/attachment-0001.gif>


More information about the Ironruby-core mailing list