Skip to content

Commit 3e70311

Browse files
committed
Some optimizations
1 parent 5ff82e1 commit 3e70311

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

MonkeyLoaderWrapper/Program.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ internal class MonkeyLoaderAssemblyLoadContext(
1010
{
1111
private readonly AssemblyResolveEventHandler? _assemblyResolveEventHandler = handler;
1212

13-
internal Assembly? ExternalLoad(object? sender, ResolveEventArgs args)
14-
{
15-
var name = new AssemblyName(args.Name);
16-
return Load(name);
17-
}
18-
1913
protected override Assembly? Load(AssemblyName assemblyName)
2014
{
2115
try
@@ -194,6 +188,8 @@ internal static void Load(string[] args, string resoPath)
194188
var t = asm.GetType("StartupHook");
195189
var m = t.GetMethod("Initialize", BindingFlags.Public | BindingFlags.Static, [typeof(string), typeof(string), typeof(AssemblyLoadContext)]);
196190
m.Invoke(null, [resoPath, bepinPath, alc]);
191+
192+
AppDomain.CurrentDomain.AssemblyResolve -= BepisLoader.BepisResolveGameDll;
197193
}
198194

199195
#if DEBUG
@@ -235,15 +231,13 @@ internal static void Load()
235231
return null;
236232
});
237233

238-
// This causes problems
234+
// This might cause problems
239235
//loadContext.Resolving += (context, assembly)
240-
//=> throw new Exception("This should never happen, we need to know about all assemblies ahead of time through ML");
236+
//=> throw new Exception("This should never happen, we need to know about all assemblies ahead of time through ML");
241237

242238
// https://github.com/dotnet/runtime/blob/main/docs/design/features/AssemblyLoadContext.ContextualReflection.md
243239
using var contextualReflection = loadContext.EnterContextualReflection();
244240

245-
AppDomain.CurrentDomain.AssemblyResolve += loadContext.ExternalLoad;
246-
247241
var monkeyLoaderAssembly = loadContext.LoadFromAssemblyPath(_monkeyLoaderPath.FullName);
248242

249243
var systemManagementPath = RuntimeInformation.RuntimeIdentifier.StartsWith("win")

0 commit comments

Comments
 (0)