/// <summary> /// 将文件转换为程序集,并加载到域 /// </summary> /// <param name="path">外部文件</param> /// <returns></returns> public virtual Assembly LoadAssemblyFromFile(string path) { Assembly assembly; if (Name == "Default") { assembly = Default.LoadFromAssemblyPath(path); } else { assembly = LoadFromAssemblyPath(path); } if (assembly != null) { using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { AddReferencesFromAssemblyStream(assembly, stream); } } AddAssemblyEvent?.Invoke(assembly); return(assembly); }
/// <summary> /// 将流转换为程序集,并加载到域 /// [手动释放] /// </summary> /// <param name="stream">外部流</param> /// <returns></returns> public virtual Assembly LoadAssemblyFromStream(Stream stream) { using (stream) { Assembly assembly; if (Name == "Default") { assembly = Default.LoadFromStream(stream); } else { assembly = LoadFromStream(stream); } if (assembly != null) { #if DEBUG Debug.WriteLine($"已加载程序集 {assembly.FullName}!"); #endif stream.Seek(0, SeekOrigin.Begin); AddReferencesFromAssemblyStream(assembly, stream); } AddAssemblyEvent?.Invoke(assembly); return(assembly); } }
/// <summary> /// 将流转换为程序集,并加载到域 /// [手动释放] /// </summary> /// <param name="stream">外部流</param> /// <returns></returns> public virtual Assembly LoadAssemblyFromStream(Stream stream) { Assembly assembly; if (Name == "Default") { assembly = Default.LoadFromStream(stream); } else { assembly = LoadFromStream(stream); } AddAssemblyEvent?.Invoke(assembly); return(assembly); }
/// <summary> /// 将文件转换为程序集,并加载到域 /// </summary> /// <param name="path">外部文件</param> /// <returns></returns> public virtual Assembly LoadAssemblyFromFile(string path) { Assembly assembly; if (Name == "Default") { assembly = Default.LoadFromAssemblyPath(path); } else { assembly = LoadFromAssemblyPath(path); } AddAssemblyEvent?.Invoke(assembly); return(assembly); }
/// <summary> /// 将流转换为程序集,并加载到域 /// [手动释放] /// </summary> /// <param name="stream">外部流</param> /// <returns></returns> public virtual Assembly LoadAssemblyFromStream(Stream stream) { using (stream) { Assembly assembly; if (Name == "Default") { assembly = Default.LoadFromStream(stream); } else { assembly = LoadFromStream(stream); } if (assembly != null) { stream.Seek(0, SeekOrigin.Begin); AddReferencesFromAssemblyStream(assembly, stream); } AddAssemblyEvent?.Invoke(assembly); return(assembly); } }