public static bool Launch() { if (Debugger.IsAttached) { return(true); } try { new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); } catch (SecurityException) { return(false); } return(Debugger.LaunchInternal()); }