[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) { AppDomain.CheckLoadByteArraySupported(); if (rawAssembly == null) throw new ArgumentNullException(nameof(rawAssembly)); AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); MemoryStream assemblyStream = new MemoryStream(rawAssembly); MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null; return alc.LoadFromStream(assemblyStream, symbolStream); }
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) { Contract.Ensures(Contract.Result <Assembly>() != null); Contract.Ensures(!Contract.Result <Assembly>().ReflectionOnly); AppDomain.CheckLoadByteArraySupported(); if (rawAssembly == null) { throw new ArgumentNullException(nameof(rawAssembly)); } AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); MemoryStream assemblyStream = new MemoryStream(rawAssembly); MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null; return(alc.LoadFromStream(assemblyStream, symbolStream)); }
// Loads the assembly with a COFF based IMAGE containing // an emitted assembly. The assembly is loaded into a fully isolated ALC with resolution fully deferred to the AssemblyLoadContext.Default. // The second parameter is the raw bytes representing the symbol store that matches the assembly. public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) { if (rawAssembly == null) { throw new ArgumentNullException(nameof(rawAssembly)); } #if FEATURE_APPX if (ApplicationModel.IsUap) { throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)")); } #endif AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); MemoryStream assemblyStream = new MemoryStream(rawAssembly); MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null; return(alc.LoadFromStream(assemblyStream, symbolStream)); }
// Loads the assembly with a COFF based IMAGE containing // an emitted assembly. The assembly is loaded into a fully isolated ALC with resolution fully deferred to the AssemblyLoadContext.Default. // The second parameter is the raw bytes representing the symbol store that matches the assembly. public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) { if (rawAssembly == null) { throw new ArgumentNullException(nameof(rawAssembly)); } #if FEATURE_APPX if (ApplicationModel.IsUap) { throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)")); } #endif SerializationInfo.ThrowIfDeserializationInProgress("AllowAssembliesFromByteArrays", ref s_cachedSerializationSwitch); AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); MemoryStream assemblyStream = new MemoryStream(rawAssembly); MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null; return(alc.LoadFromStream(assemblyStream, symbolStream)); }