0

I'm following this. A simple example of calling IronPython from C# with MonoDev:

Python:

class Hello:
    def __init__(self):
        pass
    def add(self, x, y):
        return (x+y)

C#:

using System;
using IronPython.Hosting;
using IronPython.Runtime;
using IronPython;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting;

class Hello {
    public static void Main()
    {
        ScriptEngine engine = Python.CreateEngine();
        ScriptSource script = engine.CreateScriptFromSourceFile("myPythonScript.py");
        ScriptScope scope = engine.CreateScope();

        script.Execute(scope);
    }
}

I had several problems with the assemblies doing the same kind of examples. And now my problem is that each time the program tries to do: ScriptEngine engine = Python.CreateEngine();, I get the following error:

System.Reflection.TargetInvocationException: 
Failed to load language 'IronPython 2.7.3': 
An exception was thrown by the type initializer for 
IronPython.Runtime.ExtensionMethodSet ---> System.Exception: 
An exception was thrown by the type initializer for 
IronPython.Runtime.ExtensionMethodSet ---> System.Exception: 
Could not load type 'IronPython.Runtime.ExtensionMethodSet+AssemblyLoadInfo[]' 
from assembly 'IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=7f709c5b713576e1'.

Following advice found in this forum, I've got to admit that I don't have Microsoft.Scripting.Debugging.dll because I don't know where it can be downloaded - it is not furnished with IronPython. Could you tell me where I can get it and if it's the reason why I'm still stuck on this basic example?

2
  • Note the mismatch in version numbers. This is the kind of error you'll get from that. Commented Jul 11, 2012 at 1:58
  • Thank you very much. Now I'm using IronPython 2.7.0 instead of the newest version, and everything is perfect. Commented Jul 11, 2012 at 10:01

1 Answer 1

0
ScriptScope scope = engine.CreateScope();

should be

dynamic scope = engine.CreateScope();

ScriptScope is the base class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.