Running IronPython object from C# with dynamic keyword?

Yes, dynamic can make your code simplier var source = @" class : def __init__(self): pass def add(self, x, y): return (x+y) "; var engine = Python.CreateEngine(); var scope = engine.CreateScope(); var ops = engine. Operations; engine. Execute(source, scope); var pythonType = scope.

GetVariable(" dynamic instance = ops. CreateInstance(pythonType); var value = instance. Add(10, 20); Console.

WriteLine(value); Console. WriteLine("Press any key to exit. "); Console.ReadLine().

Desco : I ran the code to get the following error. Unhandled Exception: Microsoft.CSharp.RuntimeBinder. RuntimeBinderException: IronPython.Runtime.Types.

OldInstance' does not contain a definition for add' at (wrapper dynamic-method) object.CallSite. Target (System.Runtime. CompilerServices.

Closure,System.Runtime. CompilerServices. CallSit?

E,object,int,int) at System.Dynamic.UpdateDelegates. UpdateAndExecute3 (System.Runtime. CompilerServices.

CallSite,object,int,int) at BasicEmbedding.Program. Main () – prosseek Oct 11 '10 at 20:57 @desco : I use mono 2.6 that supports . NET 4.0.

– prosseek Oct 11 '10 at 21:10 that's strange, this code works on Windows. – desco Oct 11 '10 at 21:18 just interesting, in your python sources, replace 'class :' to 'class (object):' – desco Oct 11 '10 at 21:20 @desco : I copied the py. Exe to Windows, and I got the same error.It might be that Mono 2.6 might not support DRL fully.

– prosseek Oct 11 '10 at 21:30.

Your browser didn't send a complete request in time.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions