您的位置:首页 > 编程语言 > C#

Program.cs 累积_C#

2014-05-13 10:30 211 查看
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using UtilityClass;

namespace Program
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
// 增加捕获
ApplicationEventHandlerClass AppEvents = new ApplicationEventHandlerClass();
Application.ThreadException += new ThreadExceptionEventHandler(AppEvents.OnThreadException);

// 开始监听
Trace.Listeners.Clear();
Trace.Listeners.Add(new TraceLog(Application.StartupPath + "\\Error.Log"));

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (new FormLogin().ShowDialog() == DialogResult.OK)
Application.Run(FormMain.Instance);
}

public class ApplicationEventHandlerClass
{
public void OnThreadException(object sender, ThreadExceptionEventArgs e)
{
Trace.Write(e.Exception, "未捕获的异常");
ShowMsg.ShowErr(sender as IWin32Window, "程序出现错误:\r\n" + e.Exception.Message + "\r\n\r\n请联系管理员以解决此问题!");
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: