This project has moved. For the latest updates, please go here.

Debugging Iron Python hosted in a C# application?

Mar 14, 2011 at 1:44 PM

Is it possible to use PTVS for debugging scripts running in Iron Python hosted in a C# application?

Mar 14, 2011 at 10:42 PM

If you're hosting an entire IronPython interpreter this should be doable (as should an entire CPython interpreter hosted inside a C++ application). We'll update with detailed instructions once we've figured out how to do it.

If you've compiled the IronPython down into a library you're probably out of luck.

Mar 15, 2011 at 8:24 AM
Edited Mar 15, 2011 at 8:28 AM

What do you mean by "hosting an entire IronPython interpreter"? Calling out to a separate interpreter process like this:

Start.Process("ipy.exe", "")

? (That would not really help us.)

And by "If you've compiled the IronPython down into a library"? Would using the official IronPython.dll etc. fall in that category?

var engine = IronPython.Hosting.Python.CreateEngine();

That could never work with PTVS? (Too bad. That would really help us!)

Mar 16, 2011 at 5:17 PM

You can try to use Debug - > Attach to Process...

Mar 16, 2011 at 11:46 PM

You'll need to setup debug mode on the ScriptRuntime (which can be set on the ScriptRuntimeSetup object) in order for the Python code to be debuggable.  Once you do that Attach to Process w/ .NET debugging should work.

Mar 17, 2011 at 11:40 AM

Thanks for the hint.

engine = IronPython.Hosting.Python.CreateEngine(new Dictionary<string, object>() { { "Debug", true } });
This also enables the ScriptRuntime DebugMode, and I can debug while the debugger is attached to the C# project. Very cool!