private static bool DisplayError(Exception exception, IFwMainWnd parent)
{
try
{
// To disable displaying a message box, put
// <add key="ShowUI" value="False"/>
// in the <appSettings> section of the .config file (see MSDN for details).
if (ShowUI)
{
bool fIsLethal = !(exception is ConfigurationException ||
exception is ContinuableErrorException ||
exception.InnerException is ContinuableErrorException);
if (SafelyReportException(exception, parent, fIsLethal))
{
// User chose to exit the application. Make sure that the program can be
// properly shut down after displaying the exception. (FWR-3179)
ResetStateForForcedShutdown();
return true;
}
return false;
}
// Make sure that the program can be properly shut down after displaying the exception. (FWR-3179)
ResetStateForForcedShutdown();
if (exception is ExternalException
&& (uint)(((ExternalException)exception).ErrorCode) == 0x8007000E) // E_OUTOFMEMORY
{
Trace.Assert(false, ResourceHelper.GetResourceString("kstidMiscError"),
ResourceHelper.GetResourceString("kstidOutOfMemory"));
return true;
}
Debug.Assert(exception.Message != string.Empty || exception is COMException,
"Oops - we got an empty exception description. Change the code to handle that!");
Exception innerE = ExceptionHelper.GetInnerMostException(exception);
string strMessage = ResourceHelper.GetResourceString("kstidProgError")
+ ResourceHelper.GetResourceString("kstidFatalError");
string strReport = string.Format(ResourceHelper.GetResourceString("kstidGotException"),
SupportEmail, exception.Source, Version,
ExceptionHelper.GetAllExceptionMessages(exception), innerE.Source,
innerE.TargetSite.Name, ExceptionHelper.GetAllStackTraces(exception));
Trace.Assert(false, strMessage, strReport);
}
catch
{
// we ignore any exceptions that might happen during reporting this error
}
return true;
}