是否可以从混合C ++ / CLI代码调用IronPython?(Is it possible to call IronPython from mixed C++/CLI code?)

编程入门 行业动态 更新时间:2024-10-06 08:28:08
是否可以从混合C ++ / CLI代码调用IronPython?(Is it possible to call IronPython from mixed C++/CLI code?)

我有一个本机C / C ++项目(MSVC2010),它需要访问IronPython脚本。 我能够使用这个博客文章包含C ++ / CLI代码。 但是,当我添加这样的代码时:

ScriptEngine^ engine = Python::CreateEngine(); ScriptScope^ scope = engine->CreateScope();

(摘自http://oldschooldotnet.blogspot.co.uk/2011/04/scripting-ccli-with-ironpython-visual.html ),编译器抱怨它无法找到ScriptEngine。 我应该包括什么? IronPython类实际上是否可用于C ++ / CLI?

I have a native C/C++ project (MSVC2010), which needs to access IronPython scripts. I was able to include C++/CLI code using this blogpost. However, when I add code like this:

ScriptEngine^ engine = Python::CreateEngine(); ScriptScope^ scope = engine->CreateScope();

(taken from http://oldschooldotnet.blogspot.co.uk/2011/04/scripting-ccli-with-ironpython-visual.html), the compiler complains that it can't find ScriptEngine. What should I include? Are the IronPython classes actually available for C++/CLI?

最满意答案

您需要确保您的项目具有适当的参考。 这将包括Microsoft.Scripting.Dll和Microsoft.Dynamic.dll (以及System.Core.dll )。

完成后,您还需要using语句添加适当的命名空间:

using namespace IronPython; using namespace IronPython::Hosting; using namespace IronPython::Runtime; using namespace Microsoft::Scripting; using namespace Microsoft::Scripting::Hosting;

You need to make sure your project has the appropriate references. This would include Microsoft.Scripting.Dll and Microsoft.Dynamic.dll (as well as System.Core.dll).

Once you do that, you'll need to add the appropriate namespace using statements, as well:

using namespace IronPython; using namespace IronPython::Hosting; using namespace IronPython::Runtime; using namespace Microsoft::Scripting; using namespace Microsoft::Scripting::Hosting;

更多推荐

本文发布于:2023-08-07 13:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   IronPython   CLI   code   mixed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!