質問

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