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?

Community
  • 1
  • 1
ssx
  • 184
  • 1
  • 4
  • 13

1 Answers1

0
ScriptScope scope = engine.CreateScope();

should be

dynamic scope = engine.CreateScope();

ScriptScope is the base class.

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71