문제

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