本文整理汇总了C#中System.UnhandledExceptionEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# UnhandledExceptionEventArgs类的具体用法?C# UnhandledExceptionEventArgs怎么用?C# UnhandledExceptionEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnhandledExceptionEventArgs类属于System命名空间,在下文中一共展示了UnhandledExceptionEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CurrentDomain_UnhandledException
private static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
{
if (e != null && e.ExceptionObject != null)
{
log.Error("Error: " + e.ExceptionObject);
}
}
示例2: Application_UnhandledException
private static void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject != null) {
Exception ex = (Exception)e.ExceptionObject;
MessageBox.Show(ex.Message, "Application exception");
}
}
示例3: CurrentDomain_UnhandledException
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception error = e.ExceptionObject as Exception;
string errorMessage = string.Format("An unhandled exception occurred: {0}", error);
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
示例4: CurrentDomain_UnhandledException
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (m_Log != null)
{
m_Log.Error("The process crashed for an unhandled exception!", (Exception)e.ExceptionObject);
}
}
示例5: CurrentDomain_UnhandledException
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Tracer.Fatal(e.ExceptionObject);
try
{
string timeStamp = GetTimeStamp();
string fileName = String.Format("Crash {0}.log", timeStamp);
string root = GetRoot();
string filePath = Combine(root, fileName);
using (StreamWriter writer = new StreamWriter(filePath))
{
Version version = Assembly.GetEntryAssembly().GetName().Version;
writer.WriteLine("Crash Report");
writer.WriteLine("===================");
writer.WriteLine();
writer.WriteLine("Version {0}.{1}, Build {2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
writer.WriteLine("Operating System: {0}", Environment.OSVersion);
writer.WriteLine(".NET Framework: {0}", Environment.Version);
writer.WriteLine("Time: {0}", DateTime.Now);
writer.WriteLine();
writer.WriteLine("Trace Message:");
writer.WriteLine(e.ExceptionObject);
writer.WriteLine();
}
}
catch { } //Swallow it.
}
示例6: CurrentDomain_UnhandledException
/// <summary>
/// Handles unhandled exceptions within the application.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The event arguments.</param>
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception ex = e.ExceptionObject as Exception;
DialogResult result = MessageBox.Show(Strings_General.BugReportRequest, "Doh!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (result == DialogResult.Yes)
{
ErrorLog log = new ErrorLog(ex);
XmlSerializer serializer = new XmlSerializer(typeof(ErrorLog));
using (TextWriter writer = new StringWriter())
{
serializer.Serialize(writer, log);
PostErrorLog(writer.ToString());
}
}
}
catch (Exception)
{
}
finally
{
Environment.Exit(1);
}
}
示例7: CurrentDomain_UnhandledException
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception)e.ExceptionObject;
var message = ex.Message + Environment.NewLine + ex.Source + Environment.NewLine + ex.StackTrace
+ Environment.NewLine + ex.InnerException;
new Error().Add(message);
}
示例8: CurrentDomain_UnhandledException
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception ex = (Exception)e.ExceptionObject;
string errorMsg = "Alkalmazás hiba, kérem indítsa újra az alkalmazást vagy forduljon a Support-hoz " +
"a következő adatokkal:\n\n";
// Since we can't prevent the app from terminating, log this to the event log.
DEFS.ExLog(errorMsg + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace);
MessageBox.Show(errorMsg, "E-Cafe rendszer", MessageBoxButtons.AbortRetryIgnore,
MessageBoxIcon.Stop);
}
catch (Exception exc)
{
try
{
MessageBox.Show("Fatal Non-UI Error",
"Fatal Non-UI Error. Could not write the error to the event log. Reason: "
+ exc.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
}
示例9: CurrentDomain_UnhandledException
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Log.LogError("CurrentDomain_UnhandledException");
Log.LogError(e.ExceptionObject.ToString());
MessageBox.Show("A fatal error has occurred and the application must shut down", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
示例10: CurrentDomain_UnhandledException
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception)
HandleException(e.ExceptionObject as Exception);
else
HandleException(null);
}
示例11: OnUnhandledException
void OnUnhandledException(object o, UnhandledExceptionEventArgs e) {
// Let this occur one time for each AppDomain.
if (Interlocked.Exchange(ref _unhandledExceptionCount, 1) != 0)
return;
StringBuilder message = new StringBuilder("\r\n\r\nUnhandledException logged by UnhandledExceptionModule.dll:\r\n\r\nappId=");
string appId = (string) AppDomain.CurrentDomain.GetData(".appId");
if (appId != null) {
message.Append(appId);
}
Exception currentException = null;
for (currentException = (Exception)e.ExceptionObject; currentException != null; currentException = currentException.InnerException) {
message.AppendFormat("\r\n\r\ntype={0}\r\n\r\nmessage={1}\r\n\r\nstack=\r\n{2}\r\n\r\n",
currentException.GetType().FullName,
currentException.Message,
currentException.StackTrace);
}
EventLog Log = new EventLog();
Log.Source = _sourceName;
Log.WriteEntry(message.ToString(), EventLogEntryType.Error);
}
示例12: CurrentDomainOnUnhandledException
/// <summary>
/// Handles the UnhandledException event of the CurrentDomain control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.UnhandledExceptionEventArgs"/> instance containing the event data.</param>
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (!e.IsTerminating)
{
Logger.Current.Error("Unhandled exception", e.ExceptionObject as Exception);
}
}
示例13: CurrentDomainOnUnhandledException
private static void CurrentDomainOnUnhandledException(object sender,
UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
var newExc = new Exception("CurrentDomainOnUnhandledException",
unhandledExceptionEventArgs.ExceptionObject as Exception);
LogUnhandledException(newExc);
}
示例14: UncaughtThreadException
private void UncaughtThreadException(object sender, UnhandledExceptionEventArgs e)
{
if(_isUncaughtUiThreadException)
return;
var exception = e.ExceptionObject as Exception;
_logger.Fatal(exception);
}
示例15: globalException
static void globalException(object sender, UnhandledExceptionEventArgs args)
{
Exception e = (Exception)args.ExceptionObject;
Console.WriteLine("UnhandledException:\n\n" + e);
MessageBox.Show("UnhandledException:\n\n" + e, "Updater Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}