Simpler debugging of Vista Media Center plugins
almost 16 years ago
One thing that always bothered me is the workflow when debugging media center plugins.
I’m used to pressing F5 and having my debugger automatically attach to my process. This is not the way it works for media center plugins.
To launch a media center plugin you have to execute ehshell.exe, and to debug these plugins you need to attach to exexthost.exe, a different process.
So, for example, our debug option for media browser says:
-
Start external program: C:\Windows\ehome\ehshell.exe
-
Command line arguments: /entrypoint:{CE32C570-4BEC-4aeb-AD1D-CF47B91DE0B2}{FC9ABCCC-36CB-47ac-8BAB-03E8EF5F6F22}
This configuration forces media center to launch our media browser plugin on start-up.
But… it only attaches to ehshell.exe forcing us a second, very annoying step which involves hunting down ehexthost.exe in the process list and attaching to it. It’s such a waste of time.
So … I wrote a little visual studio macro to take care of this shoddy work flow:
Public Sub CompileRunAndAttachToEhExtHost()
DTE.Solution.SolutionBuild.Build(True)
DTE.Solution.SolutionBuild.Debug()
Dim trd As System.Threading.Thread = _
New System.Threading.Thread(AddressOf AttachToEhExtHost)
trd.Start()
End Sub
Public Sub AttachToEhExtHost()
Dim i As Integer = 0
Do Until i = 50
i = i + 1
Try
For Each proc In DTE.Debugger.LocalProcesses
If (proc.Name.IndexOf("ehexthost.exe") <> -1) Then
proc.Attach()
Exit Sub
End If
Next
Catch e As Exception
' dont care - stuff may be busy
End Try
Threading.Thread.Sleep(100)
Loop
End Sub
To install it:
-
Tools->Macros->Macros IDE…
-
Expand MyMacros
-
Paste the code into yor macro file
Next, bind your macro to a shortcut key
-
Tools->Options->Keyboard
-
Click on “Press shotcut keys:”
-
Press the shortcut you want (I use CTRL-SHIFT-ALT-A)
-
Start a search in the "show commands containing… " box. Search for “CompileRunAndAttachToEhExtHost”
-
Click Assign
Your done …
Now to Compile->Launch and Debug your media center plugin all you need to do is click CTRL-SHIFT-ALT-A
What happens if there are multiple instances of ehExtHost.exe running?