Skip to content

Instantly share code, notes, and snippets.

@jkotas
Created December 26, 2016 22:07
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 jkotas/0113226ff908484dca9b7353a5da51fd to your computer and use it in GitHub Desktop.
Save jkotas/0113226ff908484dca9b7353a5da51fd to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
using System.Reflection;
using System.Runtime.Loader;
class MyALC : AssemblyLoadContext
{
protected override Assembly Load(AssemblyName name)
{
return null;
}
}
class My
{
static void Work()
{
for (int i = 0; i < 1000; i++)
{
var alc = new MyALC();
var assembly = alc.LoadFromAssemblyPath(AppContext.BaseDirectory + "hello.exe");
#if false
var entry = assembly.EntryPoint;
var result = entry.GetParameters().Length > 0 ?
entry.Invoke(null, new object[] { Array.Empty<string>() }) :
entry.Invoke(null, null);
#endif
alc.Unload();
}
}
static void Main()
{
for (int i = 0; i < 20; i++)
new Thread(Work).Start();
Work();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment