Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (50 loc) · 1.62 KB
/
Copy pathProgram.cs
File metadata and controls
54 lines (50 loc) · 1.62 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
using System;
using System.IO;
using System.Reflection;
namespace Leayal.PSO2Launcher
{
static class Program
{
internal static readonly string RootDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) ?? string.Empty;
[STAThread]
static void Main(string[] args)
{
// AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
try
{
LauncherController.Initialize(args);
}
catch (Exception ex)
{
File.WriteAllText(Path.Combine(RootDirectory, "debug_01.txt"), ex.ToString());
}
finally
{
// AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
}
}
private static Assembly? CurrentDomain_AssemblyResolve(object? sender, ResolveEventArgs args)
{
var filename = GetFilenameFromAssemblyFullname(args.Name);
// Extending probing path: \bin\*;
var filepath = Path.GetFullPath(Path.Combine("bin", filename + ".dll"), RootDirectory);
if (File.Exists(filepath))
{
return Assembly.LoadFrom(filepath);
}
return null;
}
private static string GetFilenameFromAssemblyFullname(string fullname)
{
var index = fullname.IndexOf(',');
if (index == -1)
{
return fullname;
}
else
{
return fullname.Substring(0, index);
}
}
}
}