How to attach the debugger at application startup
March 4, 2008
You may have already found the solution to this in the SDK, if not; search the SDK help for “Debugging” and check the first hit.
I have created a little piece of code that makes modifying the registry key a lot easier:
(A batch file could also have done the job, but remember, I’m a software developer)
Create a WinForm app, include the class below and link its Enabled-property to the Checked-property of a Checkbox.
using System;
using Microsoft.Win32;
namespace MediaCenterDebugRegSetter
{
public static class MediaCenterAddInLaunchDebugging
{
public static bool Enabled
{
get
{
RegistryKey key = GetRegistryKey(false);
if (key != null)
{
object value = key.GetValue(“EnableAddInLaunchDebugging”);
key.Close();
return ((value != null) && ((int)value == 1));
}
return false;
}
set
{
RegistryKey key = GetRegistryKey(true);
if (key != null)
{
key.SetValue(“EnableAddInLaunchDebugging”, (value == true) ? 1 : 0, RegistryValueKind.DWord);
key.Flush();
key.Close();
}
}
}
private static RegistryKey GetRegistryKey(bool writable)
{
try
{
return Registry.CurrentUser.OpenSubKey(@”SoftwareMicrosoftWindowsCurrentVersionMedia CenterSettingsExtensibility”, writable);
}
catch
{
return null;
}
}
}
}
PS: Media Center must be restarted for the new setting to take effect.
Entry Filed under: Tools, Windows Media Center. .
3 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed
1.
caffeinecoder | March 29, 2008 at 10:24 am
Just to let you know, this does not work in the Express editions of visual studio!
2.
caffeinecoder | March 29, 2008 at 10:25 am
sorry, forgot something the “Attach to Process” option is not available in the Express Visual studio Editions.
3.
Johan van Ruth | March 29, 2008 at 9:14 pm
thanks, I wasn’t aware of that. I use the professional edition my self.