0
我试图执行在Silverlight的IronPython的脚本文件,但我发现了异常如何从silverlight 5执行ironpython脚本文件?
序列中没有匹配的元素
string importScript = "import sys" + Environment.NewLine +
"sys.path.append(r\"{0}\")" + Environment.NewLine +
"from {1} import *";
// python script to load
string fullPath = @"c:\path\myModule.py";
var engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
// import the module
string scriptStr = string.Format(importScript,Path.GetDirectoryName(fullPath),Path.GetFileNameWithoutExtension(fullPath));
var importSrc = engine.CreateScriptSourceFromString(scriptStr, Microsoft.Scripting.SourceCodeKind.File);
importSrc.Execute(scope);
// now you ca execute one-line expressions on the scope e.g.
string expr = "functionOfMyModule()";
var result = engine.Execute(expr, scope);`
请澄清错误代码 – BillyBigPotatoes
序列中没有匹配的元素,这是例外 – Vijaykumar