-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
36 lines (32 loc) · 1.33 KB
/
Program.cs
File metadata and controls
36 lines (32 loc) · 1.33 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
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
namespace SimTools
{
public static class Program
{
[STAThread]
public static void Main()
{
// ── Dependency sub-folder resolution ──────────────────────────
// Must be registered BEFORE WPF or any NuGet assembly is first
// touched. When the runtime cannot find a DLL in the app root it
// fires AssemblyLoadContext.Default.Resolving and we redirect it
// to the Dependencies sub-folder next to the executable.
AssemblyLoadContext.Default.Resolving += (context, name) =>
{
string deps = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory, "Dependencies");
string path = Path.Combine(
deps, (name.Name ?? string.Empty) + ".dll");
return File.Exists(path)
? context.LoadFromAssemblyPath(path)
: null;
};
// ── Start WPF ─────────────────────────────────────────────────
var app = new App();
app.Run();
}
}
}