我有一个本机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;更多推荐
发布评论