49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace BMS_D1000H
|
|
{
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[MTAThread]
|
|
static void Main()
|
|
{
|
|
try
|
|
{
|
|
// AppDomain Unhandled Exception Handler for .NET Compact Framework
|
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
|
|
|
Application.Run(new fmBMSMain());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
HandleFatalException(ex, "Main Exception");
|
|
}
|
|
}
|
|
|
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
{
|
|
Exception ex = e.ExceptionObject as Exception;
|
|
HandleFatalException(ex, "Domain UnhandledException");
|
|
}
|
|
|
|
private static void HandleFatalException(Exception ex, string source)
|
|
{
|
|
string msg = string.Format("[{0}] Error: {1}", source, ex != null ? ex.Message : "Unknown Error");
|
|
System.Diagnostics.Debug.WriteLine(msg);
|
|
try
|
|
{
|
|
MessageBox.Show(msg, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
|
|
}
|
|
catch
|
|
{
|
|
// Ignore if MessageBox cannot be displayed
|
|
}
|
|
}
|
|
}
|
|
} |