Пример #1
0
        public static bool VerifyGACDependencyWhidbey(NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId)
        {
            string str = refId.ToString();
            string text;

            if (targetOtherClr)
            {
                try
                {
                    text = RuntimeHost.ApplyPolicyInOtherRuntime(str);
                }
                catch (ArgumentException ex)
                {
                    return(false);
                }
                catch (COMException ex)
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    text = AppDomain.CurrentDomain.ApplyPolicy(str);
                }
                catch (ArgumentException ex)
                {
                    return(false);
                }
                catch (COMException ex)
                {
                    return(false);
                }
            }
            ReferenceIdentity referenceIdentity = new ReferenceIdentity(text);

            referenceIdentity.ProcessorArchitecture = refId.ProcessorArchitecture;
            string assemblyName = referenceIdentity.ToString();

            Logger.AddPhaseInformation(Resources.GetString("DetectingDependentAssembly"), (object)str, (object)assemblyName);
            SystemUtils.AssemblyInfo assemblyInfo = SystemUtils.QueryAssemblyInfo(AssemblyCache, SystemUtils.QueryAssemblyInfoFlags.All, assemblyName);
            if (assemblyInfo != null || referenceIdentity.ProcessorArchitecture != null)
            {
                return(assemblyInfo != null);
            }
            NativeMethods.IAssemblyName pName;
            NativeMethods.CreateAssemblyNameObject(out pName, referenceIdentity.ToString(), 1U, IntPtr.Zero);
            NativeMethods.IAssemblyEnum ppEnum;
            NativeMethods.CreateAssemblyEnum(out ppEnum, (NativeMethods.IApplicationContext)null, pName, 2U, IntPtr.Zero);
            return(ppEnum.GetNextAssembly((NativeMethods.IApplicationContext)null, out pName, 0U) == 0);
        }
Пример #2
0
        public static bool VerifyGACDependencyWhidbey(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId)
        {
            ReferenceIdentity identity;

            System.Deployment.Application.NativeMethods.IAssemblyName name;
            System.Deployment.Application.NativeMethods.IAssemblyEnum enum2;
            string str  = refId.ToString();
            string text = null;

            if (targetOtherClr)
            {
                try
                {
                    text = RuntimeHost.ApplyPolicyInOtherRuntime(str);
                    goto Label_0048;
                }
                catch (ArgumentException)
                {
                    return(false);
                }
                catch (COMException)
                {
                    return(false);
                }
            }
            try
            {
                text = AppDomain.CurrentDomain.ApplyPolicy(str);
            }
            catch (ArgumentException)
            {
                return(false);
            }
            catch (COMException)
            {
                return(false);
            }
Label_0048:
            identity = new ReferenceIdentity(text);
            identity.ProcessorArchitecture = refId.ProcessorArchitecture;
            string assemblyName = identity.ToString();

            Logger.AddPhaseInformation(Resources.GetString("DetectingDependentAssembly"), new object[] { str, assemblyName });
            SystemUtils.AssemblyInfo info = null;
            info = SystemUtils.QueryAssemblyInfo(AssemblyCache, SystemUtils.QueryAssemblyInfoFlags.All, assemblyName);
            if ((info != null) || (identity.ProcessorArchitecture != null))
            {
                return(info != null);
            }
            System.Deployment.Application.NativeMethods.CreateAssemblyNameObject(out name, identity.ToString(), 1, IntPtr.Zero);
            System.Deployment.Application.NativeMethods.CreateAssemblyEnum(out enum2, null, name, 2, IntPtr.Zero);
            return(enum2.GetNextAssembly(null, out name, 0) == 0);
        }