public static FromPath ( |
||
codebase | /// The URI to the code base. /// | |
location | string | /// The location. Must be a valid path and an existing file if supplied--defaults to null. /// |
fullname | string | /// The full name of the assembly. Defaults to null. /// |
return | IAssemblyTarget |
public static IAssemblyTarget FromPath(Uri codebase, string location = null, string fullname = null)
{
if (codebase == null)
{
throw new ArgumentNullException("codebase", "Codebase URI cannot be null!");
}
if (!File.Exists(codebase.LocalPath))
{
throw new FileNotFoundException("The target location must be an existing file!");
}
if (!string.IsNullOrEmpty(location) && !File.Exists(location))
{
throw new FileNotFoundException("The target location must be an existing file!");
}
return new AssemblyTarget()
{
CodeBase = codebase,
Location = location,
FullName = fullname,
IsDynamic = false,
};
}
/// <inheritdoc/> public IAssemblyTarget LoadAssembly(LoadMethod loadMethod, string assemblyPath, string pdbPath = null) { IAssemblyTarget target = null; var assembly = this.loader.LoadAssembly(loadMethod, assemblyPath, pdbPath); if (loadMethod == LoadMethod.LoadBits) { // Assemlies loaded by bits will have the codebase set to the assembly that loaded it. Set it to the correct path here. var codebaseUri = new Uri(assemblyPath); target = AssemblyTarget.FromPath(codebaseUri, assembly.Location, assembly.FullName); } else { target = AssemblyTarget.FromAssembly(assembly); } return(target); }