Thursday, June 16, 2011

Debugging Install Functions in Visual Studio 2010

Most of us have probably used or know of the System.Diagnostics.Debugger.Break(). For more information on Debugger.Break checkout this link http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx
Online documentation states that if no debugger is already attached, user would be prompted to attach one to executing program when the break is hit. For some reason however, this didn’t work for us when our desired breakpoint was in an OnInstall() function of an installer class.

Further digging revealed that the comments decorating the Break() call differ a bit from the online documentation:
// Summary:
// Signals a breakpoint to an attached debugger.
//
// Exceptions:
//   System.Security.SecurityException:
//     The System.Security.Permissions.UIPermission is not set to break into the
//     debugger.
[SecuritySafeCritical]
public static void Break();
Apparently, Break() only signals a breakpoint to an attached debugger as per the summary above.


Read more: Sam Abraham