/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromPath(string assemblyPath) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; if (!binder.Bind(assemblyPath, out AssemblyBindResult bindResult, out Exception exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = GetRuntimeAssembly(bindResult, assemblyPath); return(result); }
/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromByteArray(byte[] rawAssembly, byte[] pdbSymbolStore) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; if (!binder.Bind(rawAssembly, pdbSymbolStore, out AssemblyBindResult bindResult, out Exception exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = GetRuntimeAssembly(bindResult); return(result); }
/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromByteArray(byte[] rawAssembly, byte[] pdbSymbolStore) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; AssemblyBindResult bindResult; Exception exception; if (!binder.Bind(rawAssembly, pdbSymbolStore, out bindResult, out exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = null; GetNativeFormatRuntimeAssembly(bindResult, ref result); if (result != null) { return(result); } GetEcmaRuntimeAssembly(bindResult, ref result); if (result != null) { return(result); } else { throw new PlatformNotSupportedException(); } }