mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-25 19:06:35 +08:00
整理一下项目文件
This commit is contained in:
42
AIStudio.Wpf.DiagramApp/App.xaml.cs
Normal file
42
AIStudio.Wpf.DiagramApp/App.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
//注意下面的语句一定要加上,指定log4net使用.config文件来读取配置信息
|
||||
//如果是WinForm(假定程序为MyDemo.exe,则需要一个MyDemo.exe.config文件)
|
||||
//如果是WebForm,则从web.config中读取相关信息
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
namespace AIStudio.Wpf.DiagramApp
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
public App()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
Application.Current.DispatcherUnhandledException += Application_DispatcherUnhandledException;
|
||||
}
|
||||
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
//记录严重错误
|
||||
log.Fatal(e.Exception);
|
||||
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
|
||||
}
|
||||
|
||||
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
//记录严重错误
|
||||
log.Fatal(e.ExceptionObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user