This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
63 lines (49 loc) · 1.69 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using CodeIDX.Helpers;
using CodeIDX.Services;
using CodeIDX.ViewModels.Commands;
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.IO;
namespace CodeIDX
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private string _exePath;
public App()
{
if(!SingleInstanceService.Start())
Environment.Exit(0);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
ErrorProvider.Instance.Init();
_exePath = System.IO.Path.GetFullPath(
System.Environment.GetCommandLineArgs()[0]);
ErrorProvider.Instance.LogInfo("Starting " + _exePath);
Settings.CodeIDXSettings.UpgradeAll();
Exit += App_Exit;
}
void App_Exit(object sender, ExitEventArgs e)
{
SingleInstanceService.Stop();
ErrorProvider.Instance.LogInfo("Ending " + _exePath);
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ErrorProvider.Instance.LogError(string.Empty, (Exception)e.ExceptionObject);
MessageBox.Show("An error occured.\nSee the log (in Local App DATA\\CodeIDX) for details.", "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error);
SingleInstanceService.Stop();
Environment.Exit(1);
}
}
}