static void CreateAndLoadContext(CollectibleChecker checker) { var alc = new ResourceAssemblyLoadContext(true); checker.SetAssemblyLoadContext(0, alc); alc.Unload(); // Check that any attempt to load an assembly after an explicit Unload will fail Assert.Throws <InvalidOperationException>(() => alc.LoadFromAssemblyPath(Path.GetFullPath("none.dll"))); }