将 IronPython 嵌入到我的 C# 应用程序中的最佳方法是什么?
我有一个由相当精通技术的人使用的应用程序,他们想要可编程性的小岛,所以我使用了嵌入式 Iron Python。
然而,自 IronPython 2.0 Eval() 起不再起作用。 具体来说,我无法同时加载模块和注入局部变量。
有一个解决办法,我仍然可以调用 Execute(),打印出我的答案并收听 StandardOut,但随后它会以字符串形式出现,并且我丢失了类型。
这并不是一场长期的灾难,但对于更复杂的对象来说却是一个巨大的痛苦。
有谁知道如何让 Eval() 在 2.0 中像在 1.x 中那样再次工作?
干杯, 扬
I have an application used by pretty tech-savey people and they want small island of programmability so I've used embedded Iron Python.
However, since IronPython 2.0 Eval() doesn't work any more. Specifically I can't both load modules and inject local variables.
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.
Does anyone know how to get Eval() working again in 2.0 like it did in 1.x?
Cheers,
Jan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您能否更具体地说明问题,并提供一个代码示例? “eval”风格的功能肯定仍然存在,尽管正如您所注意到的,自 1.0 以来,托管接口已经发生了很大的变化。
这在 beta 5 中有效:
顺便说一句,使用正确的
SourceCodeKind
在这里至关重要。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.
This works in beta 5:
By the way, using the right
SourceCodeKind
is critical here.这个例子可能对您有帮助: http://www.voidspace.org.uk/ironpython/ dlr_hosting.shtml
This example may help you: http://www.voidspace.org.uk/ironpython/dlr_hosting.shtml