Created
December 26, 2016 22:07
-
-
Save jkotas/0113226ff908484dca9b7353a5da51fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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