Check if application was started from within Visual Studio debug session
For those working with Windows API, there's a function which allows you to see if any debugger is present using:
if( IsDebuggerPresent() )
{
...
}
Reference: http://msdn.microsoft.com/en-us/library/ms680345.aspx
Try: System.Diagnostics.Debugger.IsAttached