Beispiel #1
0
        internal static RuntimeAssembly InternalLoadAssemblyName(
            AssemblyName assemblyRef,
            RuntimeAssembly reqAssembly,
            ref StackCrawlMark stackMark,
            IntPtr pPrivHostBinder,
            bool throwOnFileNotFound,
            IntPtr ptrLoadContextBinder = default(IntPtr))
        {
            if (assemblyRef == null)
            {
                throw new ArgumentNullException(nameof(assemblyRef));
            }
            Contract.EndContractBlock();

            if (assemblyRef.CodeBase != null)
            {
                AppDomain.CheckLoadFromSupported();
            }

            assemblyRef = (AssemblyName)assemblyRef.Clone();
            if (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None)
            {
                // PA does not have a semantics for by-name binds for execution
                assemblyRef.ProcessorArchitecture = ProcessorArchitecture.None;
            }

            String codeBase = VerifyCodeBase(assemblyRef.CodeBase);

            return(nLoad(assemblyRef, codeBase, reqAssembly, ref stackMark,
                         pPrivHostBinder,
                         throwOnFileNotFound, ptrLoadContextBinder));
        }
Beispiel #2
0
        internal static RuntimeAssembly InternalLoadAssemblyName(
            AssemblyName assemblyRef,
            Evidence assemblySecurity,
            RuntimeAssembly reqAssembly,
            ref StackCrawlMark stackMark,
#if FEATURE_HOSTED_BINDER
            IntPtr pPrivHostBinder,
#endif
            bool throwOnFileNotFound,
            bool forIntrospection,
            bool suppressSecurityChecks)
        {
            if (assemblyRef == null)
            {
                throw new ArgumentNullException("assemblyRef");
            }
            Contract.EndContractBlock();

            if (assemblyRef.CodeBase != null)
            {
                AppDomain.CheckLoadFromSupported();
            }

            assemblyRef = (AssemblyName)assemblyRef.Clone();
#if FEATURE_VERSIONING
            if (!forIntrospection &&
                (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None))
            {
                // PA does not have a semantics for by-name binds for execution
                assemblyRef.ProcessorArchitecture = ProcessorArchitecture.None;
            }
#endif

            if (assemblySecurity != null)
            {
#if FEATURE_CAS_POLICY
                if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
                {
                    throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
                }
#endif // FEATURE_CAS_POLICY

                if (!suppressSecurityChecks)
                {
#if FEATURE_MONO_CAS
#pragma warning disable 618
                    new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
#pragma warning restore 618
#endif
                }
            }

            return((RuntimeAssembly)Assembly.Load(assemblyRef));
        }