www.pudn.com > UptoLog_SomeTestApplication.zip > Program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using UptoLog.Satellite;
namespace SomeWindowsApplication
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
UptoLogEvents.SetupUptoLogEvents();
// Add the event handler for handling UI thread exceptions to the event.
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// Add the event handler for handling non-UI thread exceptions to the event.
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new SomeForm());
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
// Logged as a fatal error.
Log.LogFatalError(e.Exception);
if (e.Exception != null)
{
MessageBox.Show(e.Exception.Message, "Fatal Error (in ThreadException)");
}
Application.Exit();
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show("Hallo!!!, fejlen: " + e.ExceptionObject.ToString());
if (e.IsTerminating)
{
// Logged as a fatal error.
Log.LogFatalError(e.ExceptionObject as Exception);
if (e.ExceptionObject != null)
{
MessageBox.Show(((Exception)e.ExceptionObject).Message, "Fatal Error (in UnhandledException)");
}
}
else
{
// Logged as an error.
Log.LogError(e.ExceptionObject as Exception);
if (e.ExceptionObject != null)
{
MessageBox.Show(((Exception)e.ExceptionObject).Message, "Error (in UnhandledException)");
}
}
}
}
}