forked from OlympicAngel/StreamerPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
71 lines (61 loc) · 2.18 KB
/
Program.cs
File metadata and controls
71 lines (61 loc) · 2.18 KB
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
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace StreamerPlusApp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
Application.Run(new Main());
}
catch (Exception e)
{
Program.Application_ApplicationExit(e);
}
}
private static void Application_ApplicationExit(Exception e)
{
string filePath = Environment.CurrentDirectory + "/Error.txt";
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("-----------------------------------------------------------------------------");
while (e != null)
{
writer.WriteLine(e.GetType().FullName);
writer.WriteLine("Message : " + e.Message);
writer.WriteLine("StackTrace : " + e.StackTrace);
e = e.InnerException;
}
}
}
public static Assembly Resolver(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("CefSharp"))
{
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
assemblyName);
return File.Exists(archSpecificPath)
? Assembly.LoadFile(archSpecificPath)
: null;
}
return null;
}
}
}