3 using System
.Reflection
;
5 namespace System
.Runtime
.Loader
7 public abstract class AssemblyLoadContext
9 protected abstract Assembly
Load(AssemblyName assemblyName
);
11 protected Assembly
LoadFromAssemblyPath(string assemblyPath
)
13 if (assemblyPath
== null)
14 throw new ArgumentNullException("assemblyPath");
16 if (!Path
.IsPathRooted(assemblyPath
))
17 throw new ArgumentException("Gimme an absolute path " + assemblyPath
+ " XXX " + Path
.GetPathRoot(assemblyPath
), "assemblyPath");
19 return Assembly
.LoadFrom (assemblyPath
);
22 public Assembly
LoadFromAssemblyName(AssemblyName assemblyName
)
24 // AssemblyName is mutable. Cache the expected name before anybody gets a chance to modify it.
25 string requestedSimpleName
= assemblyName
.Name
;
27 Assembly assembly
= Load(assemblyName
);
29 throw new FileLoadException("File not found", requestedSimpleName
);
34 public static AssemblyName
GetAssemblyName(string assemblyPath
)
36 if (!File
.Exists (assemblyPath
))
37 throw new Exception ("file not found");
38 return new AssemblyName (Path
.GetFileName (assemblyPath
));