public void Test2() { var loader = new IsolationAssemblyLoadContext(Path.Combine(classBNormalPath, "ClassB.dll")); var assembly = loader.Load(); Assert.NotNull(assembly); var types = assembly.GetTypes(); loader = new IsolationAssemblyLoadContext(Path.Combine(classBIsolationPath, "ClassB/ClassB.dll")); assembly = loader.Load(); Assert.NotNull(assembly); types = assembly.GetTypes(); loader = new IsolationAssemblyLoadContext(Path.Combine(classBIsolationErrorPath, "ClassB/ClassB.dll")); assembly = loader.Load(); loader.Resolving += Loader_Resolving; Assert.NotNull(assembly); var types2 = assembly.GetTypes(); Assert.NotEqual(types2[0].BaseType, types[0].BaseType); // 默认载入器会自动从当前目录解析程序集 var loader2 = Assembly.LoadFile(Path.Combine(classBIsolationErrorPath, "ClassB/ClassB.dll")); assembly = loader.Load(); Assert.NotNull(assembly); types = assembly.GetTypes(); }
public void Test1() { var loader = new IsolationAssemblyLoadContext(Path.Combine(classAIsolationPath, "ClassA/ClassA.dll")); var assembly = loader.Load(); Assert.NotNull(assembly); var types = assembly.GetTypes(); // 无deps.json时将会回退通过Default方式载入 loader = new IsolationAssemblyLoadContext(Path.Combine(classANormalPath, "ClassA.dll")); assembly = loader.Load(); Assert.NotNull(assembly); types = assembly.GetTypes(); }