Sairama's Interesting Code of the Day
Take note of the Debugger.IsAttached property to find out whether the code is running in debugger or not.
if( System.Diagnostics.Debugger.IsAttached )
{
// Do special things (give more info to the development user)
Console.WriteLine("Yes, running in debugger");
}
else
{
Console.WriteLine("Not running in debugger");
}
System.Data.dll uses the above feature to debug Stored procedures. Opens a memory mapped file for enabling debugging of sprocs. It issues sp_sdidebug which is used to turn on or off TSQL debugging.
Disclaimer:
The code above shows only the features of .NET and in no way suggest/dictates/advices the usage of this particular feature.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter