public static Assembly LoadFile(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } #if FEATURE_APPX if (ApplicationModel.IsUap) { throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFile")); } #endif if (PathInternal.IsPartiallyQualified(path)) { throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path)); } string normalizedPath = Path.GetFullPath(path); Assembly result; lock (s_loadfile) { if (s_loadfile.TryGetValue(normalizedPath, out result)) { return(result); } AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); result = alc.LoadFromAssemblyPath(normalizedPath); s_loadfile.Add(normalizedPath, result); } return(result); }
public static Assembly LoadFile(String path) { Contract.Ensures(Contract.Result <Assembly>() != null); Contract.Ensures(!Contract.Result <Assembly>().ReflectionOnly); AppDomain.CheckLoadFileSupported(); Assembly result = null; if (path == null) { throw new ArgumentNullException(nameof(path)); } if (PathInternal.IsPartiallyQualified(path)) { throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(path)); } string normalizedPath = Path.GetFullPath(path); lock (s_loadfile) { if (s_loadfile.TryGetValue(normalizedPath, out result)) { return(result); } AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); result = alc.LoadFromAssemblyPath(normalizedPath); s_loadfile.Add(normalizedPath, result); } return(result); }
public static Assembly LoadFile(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (PathInternal.IsPartiallyQualified(path)) { throw new ArgumentException(SR.Format(SR.Argument_AbsolutePathRequired, path), nameof(path)); } string normalizedPath = Path.GetFullPath(path); Assembly?result; lock (s_loadfile) { if (s_loadfile.TryGetValue(normalizedPath, out result)) { return(result); } AssemblyLoadContext alc = new IndividualAssemblyLoadContext(string.Format("Assembly.LoadFile({0})", normalizedPath)); result = alc.LoadFromAssemblyPath(normalizedPath); s_loadfile.Add(normalizedPath, result); } return(result); }
public static Assembly LoadFile(String path) { AppDomain.CheckLoadFileSupported(); Assembly result = null; if (path == null) { throw new ArgumentNullException(nameof(path)); } if (PathInternal.IsPartiallyQualified(path)) { throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path)); } string normalizedPath = Path.GetFullPath(path); lock (s_loadfile) { if (s_loadfile.TryGetValue(normalizedPath, out result)) { return(result); } AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); result = alc.LoadFromAssemblyPath(normalizedPath); s_loadfile.Add(normalizedPath, result); } return(result); }