SMBLibrary/SMBServer/Program.cs
2016-12-22 20:51:16 +02:00

45 lines
No EOL
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
namespace SMBServer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ServerUI());
}
public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
HandleUnhandledException(e.Exception);
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject != null)
{
Exception ex = (Exception)e.ExceptionObject;
HandleUnhandledException(ex);
}
}
private static void HandleUnhandledException(Exception ex)
{
string message = String.Format("Exception: {0}: {1} Source: {2} {3}", ex.GetType(), ex.Message, ex.Source, ex.StackTrace);
MessageBox.Show(message, "Error");
Application.Exit();
}
}
}