有没有办法在Xamarin.Android下使用python脚本?

时间:2016-04-23 16:09:30

标签: c# android python xamarin ironpython

我知道CSharp是Xamarin中的语言,但有时候python的某些功能很棒,所以我想在Xamarin下调用python脚本。 我知道铁蛙,所以我试试吧。 我添加了一些必需的程序集,如:IronPython.dll,IronPython.Module,Microsoft.Scripting.dll ... 幸运的是,我成功构建了它并在我的Android设备上运行。 但当代码运行于:

        ScriptEngine engine = Python.CreateEngine();
        ScriptScope scope = engine.CreateScope();
        ScriptSource source = engine.CreateScriptSourceFromString("");
        source.Execute(scope);

发生错误:

   Microsoft.Scripting.InvalidImplementationException:
Type 'IronPython.Runtime.PythonContext' doesn't provide a suitable public constructor or its implementation is faulty:
 Could not load type 'IronPython.Runtime.PythonContext' from assembly 'IronPython, Version=2.7.5.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1'.

那么,是否有可能在Xamarin.Android上使用Python脚本?

2 个答案:

答案 0 :(得分:3)

简短回答,不可以。可以想象,可以将IronPython或其他一些Python运行时移植到Xamarin下工作,但这需要付出相当大的努力,据我所知,以前还没有完成。

答案 1 :(得分:1)

人们之前已经问过这个,但不,Xamarin的关键是C#(或F#),所以其他任何东西都超出了范围。我确定其他人正试图用其他语言(比如Python)做类似的事情,但不是通过Xamarin

相关问题