Exemple #1
0
 protected static AppDomain CreateDomainHelper(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
 {
     if (friendlyName == null)
     {
         throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_String"));
     }
     if (securityInfo != null)
     {
         new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
         AppDomain.CheckDomainCreationEvidence(appDomainInfo, securityInfo);
     }
     if (appDomainInfo == null)
     {
         appDomainInfo = new AppDomainSetup();
     }
     if ((appDomainInfo.AppDomainManagerAssembly == null) || (appDomainInfo.AppDomainManagerType == null))
     {
         string str;
         string str2;
         AppDomain.CurrentDomain.GetAppDomainManagerType(out str, out str2);
         if (appDomainInfo.AppDomainManagerAssembly == null)
         {
             appDomainInfo.AppDomainManagerAssembly = str;
         }
         if (appDomainInfo.AppDomainManagerType == null)
         {
             appDomainInfo.AppDomainManagerType = str2;
         }
     }
     return(AppDomain.nCreateDomain(friendlyName, appDomainInfo, securityInfo, (securityInfo == null) ? AppDomain.CurrentDomain.InternalEvidence : null, AppDomain.CurrentDomain.GetSecurityDescriptor()));
 }
Exemple #2
0
        protected static AppDomain CreateDomainHelper(string friendlyName,
                                                      Evidence securityInfo,
                                                      AppDomainSetup appDomainInfo)
        {
            if (friendlyName == null)
            {
                throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_String"));
            }

            Contract.EndContractBlock();
            // If evidence is provided, we check to make sure that is allowed.
            if (securityInfo != null)
            {
                new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();

                // Check the evidence to ensure that if it expects a sandboxed domain, it actually gets one.
                AppDomain.CheckDomainCreationEvidence(appDomainInfo, securityInfo);
            }

            if (appDomainInfo == null)
            {
                appDomainInfo = new AppDomainSetup();
            }

            // If there was no specified AppDomainManager for the new domain, default it to being the same
            // as the current domain's AppDomainManager.
            if (appDomainInfo.AppDomainManagerAssembly == null || appDomainInfo.AppDomainManagerType == null)
            {
                string inheritedDomainManagerAssembly;
                string inheritedDomainManagerType;

                AppDomain.CurrentDomain.GetAppDomainManagerType(out inheritedDomainManagerAssembly,
                                                                out inheritedDomainManagerType);

                if (appDomainInfo.AppDomainManagerAssembly == null)
                {
                    appDomainInfo.AppDomainManagerAssembly = inheritedDomainManagerAssembly;
                }
                if (appDomainInfo.AppDomainManagerType == null)
                {
                    appDomainInfo.AppDomainManagerType = inheritedDomainManagerType;
                }
            }

            // If there was no specified TargetFrameworkName for the new domain, default it to the current domain's.
            if (appDomainInfo.TargetFrameworkName == null)
            {
                appDomainInfo.TargetFrameworkName = AppDomain.CurrentDomain.GetTargetFrameworkName();
            }

            return(AppDomain.nCreateDomain(friendlyName,
                                           appDomainInfo,
                                           securityInfo,
                                           securityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : null,
                                           AppDomain.CurrentDomain.GetSecurityDescriptor()));
        }
        protected static AppDomain CreateDomainHelper(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
        {
            if (friendlyName == null)
            {
                throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_String"));
            }
            if (securityInfo != null)
            {
                new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
                AppDomain.CheckDomainCreationEvidence(appDomainInfo, securityInfo);
            }
            if (appDomainInfo == null)
            {
                appDomainInfo = new AppDomainSetup();
            }
            if (appDomainInfo.AppDomainManagerAssembly == null || appDomainInfo.AppDomainManagerType == null)
            {
                string assembly;
                string type;
                AppDomain.CurrentDomain.GetAppDomainManagerType(out assembly, out type);
                if (appDomainInfo.AppDomainManagerAssembly == null)
                {
                    appDomainInfo.AppDomainManagerAssembly = assembly;
                }
                if (appDomainInfo.AppDomainManagerType == null)
                {
                    appDomainInfo.AppDomainManagerType = type;
                }
            }
            if (appDomainInfo.TargetFrameworkName == null)
            {
                appDomainInfo.TargetFrameworkName = AppDomain.CurrentDomain.GetTargetFrameworkName();
            }
            string         friendlyName1        = friendlyName;
            AppDomainSetup setup                = appDomainInfo;
            Evidence       providedSecurityInfo = securityInfo;
            Evidence       creatorsSecurityInfo = providedSecurityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : (Evidence)null;
            IntPtr         securityDescriptor   = AppDomain.CurrentDomain.GetSecurityDescriptor();

            return(AppDomain.nCreateDomain(friendlyName1, setup, providedSecurityInfo, creatorsSecurityInfo, securityDescriptor));
        }