【发布时间】:2011-03-08 19:44:32
【问题描述】:
我正在尝试使用 c# 运行 IronPython 代码。 我创建了一个简单的控制台应用程序(.net 4)并添加了 IronPython.dll 、 IronPython.Modules.dll 和 Microsoft.Scripting 并编写了下一个代码 -
using Microsoft.Scripting.Hosting;
namespace app
{
class Program
{
static void Main(string[] args)
{
ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime();
ScriptEngine engine = runtime.GetEngine("py");
engine.Execute("print 'hello!'");
}
}
}
在尝试运行此程序时,出现异常 -
未处理的异常: System.Reflection.TargetInvocationException: 异常已被 调用的目标。 ---> System.IO.FileNotFoundException : 无法加载文件或程序集 'Microsoft.Scripting,版本=1.0.0.0, 文化 =中性,PublicKeyToken=31bf3856ad364e35' 或 它的依赖项之一。系统 找不到指定的文件。在 Core.LanguageProvider.Python..ctor(流 流)---内部异常结束 堆栈跟踪 --- 在 System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo 方法,对象 [] 参数, 签名结构&签名, RuntimeType 声明类型)在 System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo 方法,对象 [] 参数, SignatureStruct 签名,RuntimeType 声明类型)在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] 参数,CultureInfo 文化)在 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder bin der, Object[] 参数,CultureInfo 文化,对象 [] 激活属性)在 System.Activator.CreateInstance(类型 类型,BindingFlags bindingAttr,Binde r 活页夹,对象 [] 参数,CultureInfo 文化,对象[] 激活属性)在 System.Activator.CreateInstance(类型 类型,对象 [] 参数)在 Core.LanguageRuntime.RegisterLanguageProvider(类型 providerType) 在 D:\cod e\CodeRunner\Core\LanguageRuntime.cs:line 30 在 Test.Program.Main(String[] 参数)在 D:\code\CodeRunner\Test\Program.cs:lin e 19 按任意键继续。 . .
我真的,dont know what to do , searched at google and dont 找到解决方案。
我很乐意得到帮助。
【问题讨论】:
标签: exception ironpython dynamic-language-runtime