<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Charlie Owen - Debugging</title>
    <link>http://blog.retrosight.com/</link>
    <description>Charlie Owen</description>
    <language>en-us</language>
    <copyright>Charlie Owen</copyright>
    <lastBuildDate>Sat, 17 Jan 2009 00:44:23 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>charlieo@microsoft.com</managingEditor>
    <webMaster>charlieo@microsoft.com</webMaster>
    <item>
      <trackback:ping>http://blog.retrosight.com/Trackback.aspx?guid=71bf72ed-def9-4cd2-951a-9331c765d0aa</trackback:ping>
      <pingback:server>http://blog.retrosight.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.retrosight.com/PermaLink,guid,71bf72ed-def9-4cd2-951a-9331c765d0aa.aspx</pingback:target>
      <dc:creator>Charlie Owen</dc:creator>
      <wfw:comment>http://blog.retrosight.com/CommentView,guid,71bf72ed-def9-4cd2-951a-9331c765d0aa.aspx</wfw:comment>
      <wfw:commentRss>http://blog.retrosight.com/SyndicationService.asmx/GetEntryCommentsRss?guid=71bf72ed-def9-4cd2-951a-9331c765d0aa</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are an application developer on Windows Media Center you've probably
experienced some pain with our Details view of the stack trace, mostly because you
can't copy + paste nor see the entire stack traces if it is over a certain length.
Starting in Windows 7 you can now launch <strong>Event Viewer</strong> and navigate
to the <strong>Applications and Services Logs &gt; Media Center</strong> node to see
these stack traces. For example, the screenshot below is what you would see if you
ran the MarkupDebugging.mcml sample within Windows Media Center and pressed the button
labeled 'Crash The Application'. Note this is independent of the EnableErrorDetails
registry key enabling the 'Details' button on the dialog end users see when an application
crashes -- this event will always be written. This log file is one of those gathered
with the Media Center Diagnostic Tools I posted about <a href="http://blog.retrosight.com/MediaCenterDiagnosticToolsNowAvailable.aspx">here</a> making
it really helpful to communicate your applications crashes to us during the beta.
</p>
        <p>
          <img src="http://blog.retrosight.com/content/binary/EventPropertiesForMediaCenterApplicationCrashes.PNG" border="0" />
        </p>
        <img width="0" height="0" src="http://blog.retrosight.com/aggbug.ashx?id=71bf72ed-def9-4cd2-951a-9331c765d0aa" />
      </body>
      <title>Event Viewer Logs for Windows Media Center in Windows 7 Include Application Crash Information</title>
      <guid isPermaLink="false">http://blog.retrosight.com/PermaLink,guid,71bf72ed-def9-4cd2-951a-9331c765d0aa.aspx</guid>
      <link>http://blog.retrosight.com/EventViewerLogsForWindowsMediaCenterInWindows7IncludeApplicationCrashInformation.aspx</link>
      <pubDate>Sat, 17 Jan 2009 00:44:23 GMT</pubDate>
      <description>&lt;p&gt;
If you are an application developer&amp;nbsp;on&amp;nbsp;Windows Media Center you've probably
experienced some pain with our Details view of the stack trace, mostly because you
can't copy + paste nor see the entire stack traces if it is over a certain length.
Starting in Windows 7 you can now launch &lt;strong&gt;Event Viewer&lt;/strong&gt; and navigate
to the &lt;strong&gt;Applications and Services Logs &amp;gt; Media Center&lt;/strong&gt; node to see
these stack traces. For example, the screenshot below is what you would see if you
ran the MarkupDebugging.mcml sample within Windows Media Center and pressed the button
labeled 'Crash The Application'. Note this is independent of the EnableErrorDetails
registry key enabling the 'Details' button on the dialog end users see when an application
crashes -- this event will always be written. This log file is one of those gathered
with the Media Center Diagnostic Tools I posted about &lt;a href="http://blog.retrosight.com/MediaCenterDiagnosticToolsNowAvailable.aspx"&gt;here&lt;/a&gt;&amp;nbsp;making
it really helpful to communicate your applications crashes to us during the beta.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.retrosight.com/content/binary/EventPropertiesForMediaCenterApplicationCrashes.PNG" border=0&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.retrosight.com/aggbug.ashx?id=71bf72ed-def9-4cd2-951a-9331c765d0aa" /&gt;</description>
      <comments>http://blog.retrosight.com/CommentView,guid,71bf72ed-def9-4cd2-951a-9331c765d0aa.aspx</comments>
      <category>Tools</category>
      <category>Windows Media Center</category>
      <category>Debugging</category>
    </item>
    <item>
      <trackback:ping>http://blog.retrosight.com/Trackback.aspx?guid=11abce3d-25ae-43e6-80fd-6d071da445f8</trackback:ping>
      <pingback:server>http://blog.retrosight.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.retrosight.com/PermaLink,guid,11abce3d-25ae-43e6-80fd-6d071da445f8.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.retrosight.com/CommentView,guid,11abce3d-25ae-43e6-80fd-6d071da445f8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.retrosight.com/SyndicationService.asmx/GetEntryCommentsRss?guid=11abce3d-25ae-43e6-80fd-6d071da445f8</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been working on some debugging topics that will hopefully eventually be included
in the <a href="http://msdn.microsoft.com/mce/">Windows Media Center SDK</a> for <a href="http://www.microsoft.com/windowsvista/">Windows
Vista</a>, and I wanted to put some of these topics together and create an end-to-end
scenario demonstrating how you can use Visual Studio 2005 to debug your Windows Media
Center application code as it is running within Windows Media Center.
</p>
        <p>
Please note that these instructions require <a href="http://msdn.microsoft.com/vstudio/products/vspro/details/default.aspx">Visual
Studio 2005 Professional Edition</a> or higher because the lower editions of Visual
Studio 2005 (such as the <a href="http://msdn.microsoft.com/vstudio/express/">Express
Editions</a>) do not include a debugger that allows you to attach to running processes.
</p>
        <p>
As I wrote this blog post, I tried out these steps with the <a href="http://blog.mediacentersandbox.com/ct.ashx?id=8c34c463-1226-49cc-b0b8-3bbbdc2bf43c&amp;url=http%3a%2f%2fblog.retrosight.com%2fct.ashx%3fid%3dd3c1108e-6692-4e3b-a1f2-fad47c5195d8%26url%3dhttp%253a%252f%252fwww.mediacentersandbox.com%252fq%252fqspecification.zip">Q
podcast and video blog client</a> sample application that is included in the Windows
Media Center SDK.  However, the same set of steps can be used for any Windows
Media Center application that includes an add-in assembly.
</p>
        <p>
          <strong>Step 1 - Build and install the Windows Media Center application</strong>
        </p>
        <p>
The first step to start debugging your application is to compile your code in Visual
Studio 2005, install the resultant assembly to the GAC, and use RegisterMceApp.exe
or RegisterApplication to register the application so that it can be launched from
within Windows Media Center.
</p>
        <p>
          <strong>Step 2 - Enable Windows Media Center add-in launch debugging</strong>
        </p>
        <p>
Set the following registry value on your system to cause a Windows Media Center dialog
to appear when attempting to launch any add-in. The dialog will display the process
name and process ID that you can use to attach a debugger, set breakpoints, and step
through the code in your add-in that is executed when Windows Media Center attempts
to load and run it.
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\Settings\Extensibility]<br />
EnableAddInLaunchDebugging = 1 (REG_DWORD)
</p>
        </blockquote>
        <p>
          <strong>Step 3 - Launch Windows Media Center and click on the entry point to
start your add-in</strong>
        </p>
        <p>
After setting the EnableAddInLaunchDebugging registry value, launch Windows Media
Center and click on the entry point for your application.  When doing this, a
dialog box like the following will appear and you can use it to attach a debugger:
</p>
        <img alt="Windows Media Center add-in debugger attach prompt" src="http://blog.mediacentersandbox.com/content/binary/media_center_addin_debugging.png" />
        <p>
          <strong>Step 4 - Attach to the ehexthost process in Visual Studio 2005</strong>
        </p>
        <p>
After launching your application in Windows Media Cener, leave the Debug Application
dialog open and launch Visual Studio 2005 Professional or higher.  Click on the
Tools menu and choose Attach to Process...  A dialog like the following will
appear:
</p>
        <p>
        </p>
        <p>
          <img src="http://blog.mediacentersandbox.com/content/binary/vs2005_attach_to_process.png" border="0" />
        </p>
        <p>
        </p>
        <p>
This dialog lists all running processes on your system.  Locate the process name
and process ID that is listed in the Debug Application dialog in Windows Media Center,
click on it to highlight it and then click the Attach button to cause the Visual Studio
debugger to attach to the process.
</p>
        <p>
Note that if Visual Studio 2005 was already running when you clicked on your Windows
Media Center application, you may need to click the Refresh button in the Attach to
Process dialog before the process you are looking for appears in the list.
</p>
        <p>
          <strong>Step 5 - Configure symbol settings for the add-in assembly in Visual Studio
2005</strong>
        </p>
        <p>
Now that you have attached to the process, you need to configure symbol settings so
that you can set breakpoints and debug your add-in assembly code.  Open the Modules
window in Visual Studio by pressing Ctrl + Alt + U or by going to the Debug menu,
choosing Windows and then choosing Modules.
</p>
        <p>
When the Modules window appears, locate the DLL that represents your add-in assembly,
right-click on it and choose Symbol Settings...  A dialog like the following
will appear:
</p>
        <p>
          <img src="http://blog.mediacentersandbox.com/content/binary/vs2005_symbol_settings.png" border="0" />
        </p>
        <p>
Use the new folder icon to add a symbol file (.pdb) location.  Provide the full
path to the \bin\&lt;flavor&gt; directory for the built binary for your add-in assembly. 
Make sure to choose the correct &lt;flavor&gt; (either debug or release) depending
on which flavor of the add-in assembly is currently running in Windows Media Center. 
After adding the symbol file location, make sure that the check box next to the symbol
path is checked and then click OK to dismiss the symbol settings Options dialog.
</p>
        <p>
You can verify that you chose the correct symbol location by looking in the Module
window and verifying that the Symbol Status for your add-in assembly now says Symbols
Loaded.
</p>
        <p>
          <strong>Step 6 - Configure Visual Studio option to allow setting breakpoints in managed
code</strong>
        </p>
        <p>
Go to the Tools menu in Visual Studio 2005 and choose Options...  Expand the
Debugging item in the options tree and select General.  Verify that the option
named Enable Just My Code (Managed only) is checked.  Click OK to dismiss the
options dialog.
</p>
        <p>
          <strong>Step 7 - Set breakpoints and start debugging</strong>
        </p>
        <p>
Now you are ready to set some breakpoints in your source code and start debugging. 
Open up your source code files in the Visual Studio IDE and click on the line numbers
you are interested in debugging to set breakpoints.  After you have set all of
the breakpoints you want, click OK on the Debug Application dialog in Windows Media
Center to resume execution of your application.  You should see breakpoints hit
if you set them in the correct places, and you can use the Visual Studio debugger
to step through your code.
</p>
        <p>
          <strong>Step 8 - Repeat as necessary</strong>
        </p>
        <p>
If you need to start a new debugging session, you can start again at step 3 of the
above instructions.  The process ID in the Debug Application dialog will change
each time you launch your application, so you will need to make sure to attach to
the new instance of ehexthost.exe in Visual Studio 2005.
</p>
        <p>
Hopefully these steps will be useful to you as you develop your Windows Media Center
applications in Windows Vista.
</p>
        <p>
Aaron
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blog.retrosight.com/aggbug.ashx?id=11abce3d-25ae-43e6-80fd-6d071da445f8" />
      </body>
      <title>How to debug a running Windows Media Center application in Windows Vista using Visual Studio 2005</title>
      <guid isPermaLink="false">http://blog.retrosight.com/PermaLink,guid,11abce3d-25ae-43e6-80fd-6d071da445f8.aspx</guid>
      <link>http://blog.retrosight.com/HowToDebugARunningWindowsMediaCenterApplicationInWindowsVistaUsingVisualStudio2005.aspx</link>
      <pubDate>Sat, 05 Aug 2006 21:13:47 GMT</pubDate>
      <description>&lt;p&gt;
I have been working on some debugging topics that will hopefully eventually be included
in the &lt;a href="http://msdn.microsoft.com/mce/"&gt;Windows Media Center SDK&lt;/a&gt; for &lt;a href="http://www.microsoft.com/windowsvista/"&gt;Windows
Vista&lt;/a&gt;, and I wanted to put some of these topics together and create an end-to-end
scenario demonstrating how you can use Visual Studio 2005 to debug your Windows Media
Center application code as it is running within Windows Media Center.
&lt;/p&gt;
&lt;p&gt;
Please note that these instructions require &lt;a href="http://msdn.microsoft.com/vstudio/products/vspro/details/default.aspx"&gt;Visual
Studio 2005 Professional Edition&lt;/a&gt; or higher because the lower editions of Visual
Studio 2005 (such as the &lt;a href="http://msdn.microsoft.com/vstudio/express/"&gt;Express
Editions&lt;/a&gt;) do not include a debugger that allows you to attach to running processes.
&lt;/p&gt;
&lt;p&gt;
As I wrote this blog post, I tried out these steps with the &lt;a href="http://blog.mediacentersandbox.com/ct.ashx?id=8c34c463-1226-49cc-b0b8-3bbbdc2bf43c&amp;amp;url=http%3a%2f%2fblog.retrosight.com%2fct.ashx%3fid%3dd3c1108e-6692-4e3b-a1f2-fad47c5195d8%26url%3dhttp%253a%252f%252fwww.mediacentersandbox.com%252fq%252fqspecification.zip"&gt;Q
podcast and video blog client&lt;/a&gt; sample application that is included in the Windows
Media Center SDK.&amp;nbsp; However, the same set of steps can be used for any Windows
Media Center application that includes an add-in assembly.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step 1 - Build and install the Windows Media Center application&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The first step to start debugging your application is to compile your code in Visual
Studio 2005, install the resultant assembly to the GAC, and use RegisterMceApp.exe
or RegisterApplication to register the application so that it can be launched from
within Windows Media Center.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step&amp;nbsp;2 - Enable Windows Media Center add-in launch debugging&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Set the following registry value on your system to cause a Windows Media Center dialog
to appear when attempting to launch any add-in. The dialog will display the process
name and process ID that you can use to attach a debugger, set breakpoints, and step
through the code in your add-in that is executed when Windows Media Center attempts
to load and run it.
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\Settings\Extensibility]&lt;br&gt;
EnableAddInLaunchDebugging = 1 (REG_DWORD)
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;Step&amp;nbsp;3 - Launch Windows Media Center and click on the entry point to
start your add-in&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
After setting the EnableAddInLaunchDebugging registry value, launch Windows Media
Center and click on the entry point for your application.&amp;nbsp; When doing this, a
dialog box like the following will appear and you can use it to attach a debugger:
&lt;/p&gt;
&lt;img alt="Windows Media Center add-in debugger attach prompt" src="http://blog.mediacentersandbox.com/content/binary/media_center_addin_debugging.png"&gt; 
&lt;p&gt;
&lt;strong&gt;Step 4 - Attach to the ehexthost process in Visual Studio 2005&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
After launching your application in Windows Media Cener, leave the Debug Application
dialog open and launch Visual Studio 2005 Professional or higher.&amp;nbsp; Click on the
Tools menu and choose Attach to Process...&amp;nbsp; A dialog like the following will
appear:
&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;img src="http://blog.mediacentersandbox.com/content/binary/vs2005_attach_to_process.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
This dialog lists all running processes on your system.&amp;nbsp; Locate the process name
and process ID that is listed in the Debug Application dialog in Windows Media Center,
click on it to highlight it and then click the Attach button to cause the Visual Studio
debugger to attach to the process.
&lt;/p&gt;
&lt;p&gt;
Note that if Visual Studio 2005 was already running when you clicked on your Windows
Media Center application, you may need to click the Refresh button in the Attach to
Process dialog before the process you are looking for appears in the list.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step 5 - Configure symbol settings for the add-in assembly in Visual Studio
2005&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now that you have attached to the process, you need to configure symbol settings so
that you can set breakpoints and debug your add-in assembly code.&amp;nbsp; Open the Modules
window in Visual Studio by pressing Ctrl + Alt + U or by going to the Debug menu,
choosing Windows and then choosing Modules.
&lt;/p&gt;
&lt;p&gt;
When the Modules window appears, locate the DLL that represents your add-in assembly,
right-click on it and choose Symbol Settings...&amp;nbsp; A dialog like the following
will appear:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.mediacentersandbox.com/content/binary/vs2005_symbol_settings.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Use the new folder icon to add a symbol file (.pdb) location.&amp;nbsp; Provide the full
path to the \bin\&amp;lt;flavor&amp;gt; directory for the built binary for your add-in assembly.&amp;nbsp;
Make sure to choose the correct &amp;lt;flavor&amp;gt; (either debug or release) depending
on which flavor of the add-in assembly is currently running in Windows Media Center.&amp;nbsp;
After adding the symbol file location, make sure that the check box next to the symbol
path is checked and then click OK to dismiss the symbol settings Options dialog.
&lt;/p&gt;
&lt;p&gt;
You can verify that you chose the correct symbol location by looking in the Module
window and verifying that the Symbol Status for your add-in assembly now says Symbols
Loaded.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step 6 - Configure Visual Studio option to allow setting breakpoints in managed
code&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Go to the Tools menu in Visual Studio 2005 and choose Options...&amp;nbsp; Expand the
Debugging item in the options tree and select General.&amp;nbsp; Verify that the option
named Enable Just My Code (Managed only) is checked.&amp;nbsp; Click OK to dismiss the
options dialog.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step&amp;nbsp;7 - Set breakpoints and start debugging&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now you are ready to set some breakpoints in your source code and start debugging.&amp;nbsp;
Open up your source code files in the Visual Studio IDE and click on the line numbers
you are interested in debugging to set breakpoints.&amp;nbsp; After you have set all of
the breakpoints you want, click OK on the Debug Application dialog in Windows Media
Center to resume execution of your application.&amp;nbsp; You should see breakpoints hit
if you set them in the correct places, and you can use the Visual Studio debugger
to step through your code.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Step 8 - Repeat as necessary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If you need to start a new debugging session, you can start again at step 3 of the
above instructions.&amp;nbsp; The process ID in the Debug Application dialog will change
each time you launch your application, so you will need to make sure to attach to
the new instance of ehexthost.exe in Visual Studio 2005.
&lt;/p&gt;
&lt;p&gt;
Hopefully these steps will be useful to you as you develop your Windows Media Center
applications in Windows Vista.
&lt;/p&gt;
&lt;p&gt;
Aaron
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.retrosight.com/aggbug.ashx?id=11abce3d-25ae-43e6-80fd-6d071da445f8" /&gt;</description>
      <comments>http://blog.retrosight.com/CommentView,guid,11abce3d-25ae-43e6-80fd-6d071da445f8.aspx</comments>
      <category>Debugging</category>
    </item>
  </channel>
</rss>