Skip to content

Instantly share code, notes, and snippets.

@kevingosse
Created June 23, 2020 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevingosse/fef3757491933a4847cbead4e7cedc5c to your computer and use it in GitHub Desktop.
Save kevingosse/fef3757491933a4847cbead4e7cedc5c to your computer and use it in GitHub Desktop.
class StartupAssemblyLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;
public StartupAssemblyLoadContext()
{
_resolver = new AssemblyDependencyResolver(Assembly.GetExecutingAssembly().Location);
}
protected override Assembly Load(AssemblyName assemblyName)
{
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
return LoadFromAssemblyPath(assemblyPath);
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment