Skip to content

Instantly share code, notes, and snippets.

@devhawk
Created February 28, 2009 00:50
Show Gist options
  • Save devhawk/71804 to your computer and use it in GitHub Desktop.
Save devhawk/71804 to your computer and use it in GitHub Desktop.
import clr
clr.AddReference('CorDebug')
from System.Reflection import Assembly
ipy = Assembly.GetEntryAssembly().Location
import sys
py_file = sys.argv[1]
cmd_line = "\"%s\" -D \"%s\"" % (ipy, py_file)
from System.Threading import AutoResetEvent
evt = AutoResetEvent(False)
def _onCreateAppDomain(s,e):
print "_onCreateAppDomain", e.AppDomain.Name
e.AppDomain.Attach()
def _onProcessExit(s,e):
print "_onProcessExit"
evt.Set()
from Microsoft.Samples.Debugging.CorDebug import CorDebugger
debugger = CorDebugger(CorDebugger.GetDefaultDebuggerVersion())
process = debugger.CreateProcess(ipy, cmd_line)
process.OnCreateAppDomain += _onCreateAppDomain
process.OnProcessExit += _onProcessExit
process.Continue(False)
evt.WaitOne()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment