[IronPython] Using mdbg from IronPython

David.Lawler at franke.com David.Lawler at franke.com
Wed Sep 19 11:06:00 PDT 2007


Ok I solved my own problem (a small miracle there).
The reason that it did not work is that you have to call anything that 
uses mscordbi
(like mdbg), from an thread that is running in ApartmentState.MTA. 
Therefore,
I needed to create a second worker thread in my IronPython script running 
in
MTA mode, shove all the debugger related stuff in there, and then call it 
from
my main thread.

David Lawler/FKS/FRANKE wrote on 09/18/2007 04:51:52 PM:

> I am experimenting and learning about debugging by playing with the 
> source code to mdbg and the various samples.
> I thought it would be fun to take the mdbg c# example program that 
> prints out modules as they are loaded and make a
> version in IronPython (I tried IP 1.1 and 2.0A3):
> 
> import clr
> 
> clr.AddReference('mdbgeng')
> 
> from Microsoft.Samples.Debugging.MdbgEngine import *
> 
> debugger = MDbgEngine()
> debugger.Options.CreateProcessWithNewConsole = True
> debugger.Options.StopOnModuleLoad = True
> 
> proc = debugger.CreateProcess("ipy.exe", "", DebugModeFlag.Debug, None)
> 
> while (proc.IsAlive):
>     proc.Go().WaitOne()
>     o = proc.StopReason
>     if (isinstance(o) == ModuleLoadedStopReason):
>         print o.Module.CorModule.Name
> 
> print "done"
> 
> Original c# program link: http://blogs.msdn.
> com/jmstall/archive/2004/11/19/267135.aspx
> 
> Unfortunately, it does not work.  The call to proc.Go().WaitOne() 
> never returns and ipy.exe launches - but nothing is
> displayed in the window.  What am I doing wrong (or is this just too
> weird for IronPython to handle)?  Thanks,
> 
> David


More information about the Users mailing list