예제 #1
0
파일: Dispensers.cs 프로젝트: z77ma/runtime
        /// <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);
        }
예제 #2
0
파일: Dispensers.cs 프로젝트: z77ma/runtime
        /// <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);
        }
예제 #3
0
        /// <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();
            }
        }