Вопрос

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?

Это было полезно?

Решение

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;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top