| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using GalaSoft.MvvmLight.Threading;
- using System;
- using System.IO;
- using System.Linq;
- using System.Windows;
- namespace MuchInfo.Chart.App
- {
- /// <summary>
- /// App.xaml 的交互逻辑
- /// </summary>
- public partial class App : Application
- {
- static App()
- {
- CopySqliteFile();
- DispatcherHelper.Initialize();
- }
- public App()
- {
- this.DispatcherUnhandledException += App_DispatcherUnhandledException;
- AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
-
- }
- /// <summary>
- /// 处理Dispatcher线程异常
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.Windows.Threading.DispatcherUnhandledExceptionEventArgs"/> instance containing the event data.</param>
- private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
- {
- MessageBox.Show(e.Exception.Message);
- }
- /// <summary>
- /// 处理Domain异常
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
- private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- MessageBox.Show((e.ExceptionObject as Exception).Message);
- }
- private static void CopySqliteFile()
- {
- var is64 = Environment.Is64BitOperatingSystem;
- var sqliteFilePath = Environment.CurrentDirectory;
- sqliteFilePath = Path.Combine(sqliteFilePath, is64 ? "x64" : "x86");
- var dirInfo = new DirectoryInfo(sqliteFilePath);
- if (dirInfo.Exists)
- {
- var fileInfos = dirInfo.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
- if (!fileInfos.Any()) return;
- foreach (var fileInfo in fileInfos)
- {
- fileInfo.CopyTo(Path.Combine(Environment.CurrentDirectory, fileInfo.Name), true);
- }
- }
- }
- }
- }
|