私はこれに従っています。MonoDev を使用して C# から IronPython を呼び出す簡単な例:
パイソン:
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);
}
}
同じ種類の例を実行するアセンブリにいくつかの問題がありました。そして今、私の問題は、プログラムが実行しようとするたびに:
ScriptEngine engine = Python.CreateEngine();
、次のエラーが発生することです:
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'.
このフォーラムで見つかったアドバイスに従って、Microsoft.Scripting.Debugging.dll をダウンロードできる場所がわからないため、IronPython が付属していないため、Microsoft.Scripting.Debugging.dll を持っていないことを認めなければなりません。どこで入手できるのか、それがこの基本的な例にこだわる理由なのか教えていただけますか?