什么是嵌入IronPython的里面我的C#应用程序的最佳方法是什么? [英] What's the best way to embed IronPython inside my C# App?
问题描述
我用pretty的高科技savey人的申请,他们希望小岛的可编程性让我用预埋铁的Python。
I have an application used by pretty tech-savey people and they want small island of programmability so I've used embedded Iron Python.
然而,由于IronPython的2.0的eval()不工作了。具体来说,我不能同时加载模块和注射局部变量。
However, since IronPython 2.0 Eval() doesn't work any more. Specifically I can't both load modules and inject local variables.
有一个变通,我仍然可以调用execute(),打印出我的回答并听取StandardOut,但它出来作为一个字符串,我已经失去了类型。
There is a work around where I can still call Execute(), print out my answer and listen to StandardOut, but then it comes out as a string and I've lost the type.
不是一场灾难很长,但对于更复杂的对象一个巨大的痛苦。
Not a disaster for a long, but a huge pain for more complex objects.
有谁知道怎么弄的eval()在2.0再次合作像它在1.x版本做了?
Does anyone know how to get Eval() working again in 2.0 like it did in 1.x?
干杯, 扬
推荐答案
你能不能更具体一点关于这个问题,也许提供了一个code的例子吗?而EVAL式的功能是肯定还是present,但正如你已经注意到,托管接口大大自1.0改变了。
Could you be a little more specific about the problem, and maybe provide a code example? The "eval"-style functionality is definitely still present, though as you've noticed, the hosting interface has changed considerably since 1.0.
这工作处于测试阶段5:
This works in beta 5:
ScriptEngine engine = Python.CreateEngine();
ScriptSource source = engine.CreateScriptSourceFromString("2 + 5", SourceCodeKind.Expression);
int result = source.Execute<int>();
顺便说一句,使用正确的来源$ C $ cKind
这里是至关重要的。
By the way, using the right SourceCodeKind
is critical here.
这篇关于什么是嵌入IronPython的里面我的C#应用程序的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!