private void DetachHandler() { #if SILVERLIGHT //NOTE: This may not work for console hosted scenarios Application.Current.UnhandledException -= OnGlobalException; #else AppDomain.CurrentDomain.UnhandledException -= OnGlobalException; #endif }