예제 #1
0
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        internal static Type GetType_Compat(String assemblyString, String typeName)
        {
            // Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API
            // call Assembly.Load(assemblyString).GetType(typeName), therefore we take the stackMark here as well, to be fully compatible with
            // the call sequence.
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            RuntimeAssembly assembly;
            AssemblyName    assemblyName = RuntimeAssembly.CreateAssemblyName(
                assemblyString,
                false /*forIntrospection*/,
                out assembly);

            if (assembly == null)
            {
                if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
                {
                    return(Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, false /*ignoreCase*/));
                }

                assembly = RuntimeAssembly.InternalLoadAssemblyName(
                    assemblyName, null, null, ref stackMark,
                    true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
            }
            return(assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/));
        }
예제 #2
0
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
        {
            Contract.Ensures(Contract.Result <Assembly>() != null);
            Contract.Ensures(!Contract.Result <Assembly>().ReflectionOnly);

            if (assemblyRef != null && assemblyRef.CodeBase != null)
            {
                throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase"));
            }

            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            return(RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder));
        }
예제 #3
0
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        public static Assembly Load(AssemblyName assemblyRef)
        {
            Contract.Ensures(Contract.Result <Assembly>() != null);
            Contract.Ensures(!Contract.Result <Assembly>().ReflectionOnly);

            if (assemblyRef != null && assemblyRef.CodeBase != null)
            {
                throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase);
            }

            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            return(RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/));
        }
예제 #4
0
        internal static Assembly Load(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext?assemblyLoadContext)
        {
            AssemblyName modifiedAssemblyRef;

            if (assemblyRef.CodeBase != null)
            {
                modifiedAssemblyRef          = (AssemblyName)assemblyRef.Clone();
                modifiedAssemblyRef.CodeBase = null;
            }
            else
            {
                modifiedAssemblyRef = assemblyRef;
            }

            return(RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, ref stackMark, assemblyLoadContext));
        }
예제 #5
0
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
        {
            AssemblyName modifiedAssemblyRef = null;
            if (assemblyRef != null && assemblyRef.CodeBase != null)
            {
                modifiedAssemblyRef = (AssemblyName)assemblyRef.Clone();
                modifiedAssemblyRef.CodeBase = null;
            }
            else
            {
                modifiedAssemblyRef = assemblyRef;
            }

            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
            return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, ref stackMark, true /*thrownOnFileNotFound*/, ptrLoadContextBinder);
        }
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
        {
            Contract.Ensures(Contract.Result <Assembly>() != null);
            Contract.Ensures(!Contract.Result <Assembly>().ReflectionOnly);

            AssemblyName modifiedAssemblyRef = null;

            if (assemblyRef != null && assemblyRef.CodeBase != null)
            {
                modifiedAssemblyRef          = (AssemblyName)assemblyRef.Clone();
                modifiedAssemblyRef.CodeBase = null;
            }
            else
            {
                modifiedAssemblyRef = assemblyRef;
            }

            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            return(RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder));
        }
        public static Assembly Load(AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity)
        {
            StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;

            return(RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, assemblySecurity, ref lookForMyCaller, false, false));
        }
        public static Assembly Load(AssemblyName assemblyRef)
        {
            StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;

            return(RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, ref lookForMyCaller, false, false));
        }