-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProblemLoadContext.cs
39 lines (32 loc) · 1.04 KB
/
ProblemLoadContext.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
using System;
using System.Reflection;
using System.Runtime.Loader;
namespace NET_AssemblyLoadContext_IsolationProblem.EntryPoint
{
public class ProblemLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;
public ProblemLoadContext(string path)
{
_resolver = new AssemblyDependencyResolver(path);
}
protected override Assembly? Load(AssemblyName assemblyName)
{
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
return LoadFromAssemblyPath(assemblyPath);
}
return null;
}
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
var libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
if (libraryPath != null)
{
return LoadUnmanagedDllFromPath(libraryPath);
}
return IntPtr.Zero;
}
}
}