Inheritance: MarshalByRefObject
Ejemplo n.º 1
0
        public SS14UnitTest()
        {
            /*
             * Assembly.getEntryAssembly() returns null because Unit tests
             * are unmanaged and have no app domain managers.
             * this causes IOCManager to never load or build any of the types
             *
             * Fixed by Setting the Entry assembly values manually here
             */
            Assembly assembly = Assembly.GetCallingAssembly();

            AppDomainManager manager = new AppDomainManager();
            FieldInfo entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
            domainManagerField.SetValue(domain, manager);

            /* end fix */

            //ConfigurationManager setup
            GetConfigurationManager = IoCManager.Resolve<IPlayerConfigurationManager>();
            GetConfigurationManager.Initialize("./player_config.xml");

            //ResourceManager Setup
            GetResourceManager = IoCManager.Resolve<IResourceManager>();
            GetResourceManager.LoadBaseResources();
            GetResourceManager.LoadLocalResources();
        }
Ejemplo n.º 2
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public static ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData) {
            AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
            if (domainManager == null)
                domainManager = new AppDomainManager();

            return domainManager.ApplicationActivator.CreateInstance(activationContext, activationCustomData);
        }
		public void CheckSecuritySettings ()
		{
			AppDomainManager adm = new AppDomainManager ();
			Assert.IsFalse (adm.CheckSecuritySettings (null), "null");

			ContreteSecurityState ss = new ContreteSecurityState ();
			Assert.IsFalse (adm.CheckSecuritySettings (ss), "ContreteSecurityState");
		}
Ejemplo n.º 4
0
		public void Array_Critical ()
		{
			// exception occurs before reaching the code (JIT time) and the harness consider this a success
			Assert.IsFalse (true, "This fails before the method is executed");
			// critical type
			AppDomainManager [] adm = new AppDomainManager [0];
			Assert.IsNotNull (adm, "AppDomainManager[]");
		}
Ejemplo n.º 5
0
        public static ObjectHandle CreateInstance(ActivationContext activationContext)
        {
            AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;

            if (domainManager == null)
            {
                domainManager = new AppDomainManager();
            }
            return(domainManager.ApplicationActivator.CreateInstance(activationContext));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Allows setting the Entry Assembly when needed. 
        /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA ad hoc tests
        /// </summary>
        /// <param name="assembly">Assembly to set as entry assembly</param>
        public static void SetEntryAssembly(Assembly assembly)
        {
            AppDomainManager manager = new AppDomainManager();
            FieldInfo entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
            domainManagerField.SetValue(domain, manager);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Allows setting the Entry Assembly when needed. 
        /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA ad hoc tests
        /// </summary>
        /// <param name="assembly">Assembly to set as entry assembly</param>
        public static void Inject(Assembly assembly = null)
        {
            assembly = assembly ?? Assembly.GetCallingAssembly();
            var manager = new AppDomainManager();
            var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
            entryAssemblyfield.SetValue(manager, assembly);

            var domain = AppDomain.CurrentDomain;
            var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
            domainManagerField.SetValue(domain, manager);
        }
Ejemplo n.º 8
0
        public static void SetupTest(TestContext tc)
        {
            Console.WriteLine("TestBase::Setup");

            Assembly assembly = Assembly.GetExecutingAssembly();

            AppDomainManager manager = new AppDomainManager();
            FieldInfo entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
            domainManagerField.SetValue(domain, manager);  
        }
        /// <summary>Returns an application domain that can be either a new or existing domain.</summary>
        /// <returns>An <see cref="T:System.AppDomain" /> object.</returns>
        /// <param name="friendlyName">The friendly name of the domain. </param>
        /// <param name="securityInfo">An <see cref="T:System.Security.Policy.Evidence" /> object that contains evidence mapped through the security policy to establish a top-of-stack permission set.</param>
        /// <param name="appDomainInfo">An <see cref="T:System.AppDomainSetup" /> object that contains application domain initialization information.</param>
        /// <filterpriority>2</filterpriority>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence, ControlAppDomain, Infrastructure" />
        /// </PermissionSet>
        public virtual AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
        {
            this.InitializeNewDomain(appDomainInfo);
            AppDomain appDomain = AppDomainManager.CreateDomainHelper(friendlyName, securityInfo, appDomainInfo);

            if ((this.HostSecurityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel)
            {
                PolicyLevel domainPolicy = this.HostSecurityManager.DomainPolicy;
                if (domainPolicy != null)
                {
                    appDomain.SetAppDomainPolicy(domainPolicy);
                }
            }
            return(appDomain);
        }
		/// <summary>
		///     Allows setting the Entry Assembly when needed.
		///     Use SetEntryAssembly() only for tests
		/// </summary>
		/// <param name="assembly">Assembly to set as entry assembly</param>
		private static void SetEntryAssembly(Assembly assembly)
		{
			if (Assembly.GetEntryAssembly() != null)
			{
				return;
			}
			var manager = new AppDomainManager();
			var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
			if (entryAssemblyfield != null)
			{
				entryAssemblyfield.SetValue(manager, assembly);
			}

			var domain = AppDomain.CurrentDomain;
			var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
			if (domainManagerField != null)
			{
				domainManagerField.SetValue(domain, manager);
			}
		}
Ejemplo n.º 11
0
 // Token: 0x0600089A RID: 2202 RVA: 0x0001D590 File Offset: 0x0001B790
 internal void RegisterWithHost()
 {
     if (AppDomainManager.HasHost())
     {
         IntPtr intPtr = IntPtr.Zero;
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             intPtr = Marshal.GetIUnknownForObject(this);
             AppDomainManager.RegisterWithHost(intPtr);
         }
         finally
         {
             if (!intPtr.IsNull())
             {
                 Marshal.Release(intPtr);
             }
         }
     }
 }
Ejemplo n.º 12
0
        internal void RegisterWithHost()
        {
            if (!AppDomainManager.HasHost())
            {
                return;
            }
            IntPtr num = IntPtr.Zero;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                num = Marshal.GetIUnknownForObject((object)this);
                AppDomainManager.RegisterWithHost(num);
            }
            finally
            {
                if (!num.IsNull())
                {
                    Marshal.Release(num);
                }
            }
        }
Ejemplo n.º 13
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public static Assembly GetEntryAssembly() {
     AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
     if (domainManager == null)
         domainManager = new AppDomainManager();
     return domainManager.EntryAssembly;
 }
 private void CreateAppDomainManager()
 {
     string str;
     string str2;
     AppDomainSetup fusionStore = this.FusionStore;
     this.GetAppDomainManagerType(out str, out str2);
     if ((str != null) && (str2 != null))
     {
         try
         {
             new System.Security.PermissionSet(PermissionState.Unrestricted).Assert();
             this._domainManager = this.CreateInstanceAndUnwrap(str, str2) as AppDomainManager;
             CodeAccessPermission.RevertAssert();
         }
         catch (FileNotFoundException exception)
         {
             throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), exception);
         }
         catch (SecurityException exception2)
         {
             throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), exception2);
         }
         catch (TypeLoadException exception3)
         {
             throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), exception3);
         }
         if (this._domainManager == null)
         {
             throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"));
         }
         this.FusionStore.AppDomainManagerAssembly = str;
         this.FusionStore.AppDomainManagerType = str2;
         bool flag = (this._domainManager.GetType() != typeof(AppDomainManager)) && !this.DisableFusionUpdatesFromADManager();
         AppDomainSetup oldInfo = null;
         if (flag)
         {
             oldInfo = new AppDomainSetup(this.FusionStore, true);
         }
         this._domainManager.InitializeNewDomain(this.FusionStore);
         if (flag)
         {
             this.SetupFusionStore(this._FusionStore, oldInfo);
         }
         if ((this._domainManager.InitializationFlags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
         {
             this._domainManager.RegisterWithHost();
         }
     }
     this.InitializeCompatibilityFlags();
 }
Ejemplo n.º 15
0
		public void MultidimentionalArrays ()
		{
			// transparent type
			FrameworkElement [,] fe = new FrameworkElement [0, 0];
			Assert.IsNotNull (fe, "FrameworkElement[,]");

			// critical type
			AppDomainManager [,] adm = new AppDomainManager [0, 0];
			Assert.IsNotNull (adm, "AppDomainManager[,]");
		}
Ejemplo n.º 16
0
		public void Field_SecurityCritical ()
		{
			Assert.Throws<FieldAccessException> (delegate {
				Assert.IsNotNull (field, "read"); // Assert should not be executed
			}, "read");
			Assert.Throws<FieldAccessException> (delegate {
				field = null;
			}, "write");
		}
Ejemplo n.º 17
0
		bool SetCritical (AppDomainManager value)
		{
			return (value == null);
		}
Ejemplo n.º 18
0
        private void RunDomainManagerPostInitialization (AppDomainManager domainManager) {
            // force creation of the HostExecutionContextManager for the current AppDomain
            HostExecutionContextManager contextManager = domainManager.HostExecutionContextManager;

            HostSecurityManager securityManager = domainManager.HostSecurityManager;
            if (securityManager != null) {
                if ((securityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel) {
                    // set AppDomain policy if specified
                    PolicyLevel level = securityManager.DomainPolicy;
                    if (level != null)
                        SetAppDomainPolicy(level);
                }
            }
        }
Ejemplo n.º 19
0
 private void RunDomainManagerPostInitialization(AppDomainManager domainManager)
 {
     HostExecutionContextManager hostExecutionContextManager = domainManager.HostExecutionContextManager;
     System.Security.HostSecurityManager hostSecurityManager = domainManager.HostSecurityManager;
     if ((hostSecurityManager != null) && ((hostSecurityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel))
     {
         PolicyLevel domainPolicy = hostSecurityManager.DomainPolicy;
         if (domainPolicy != null)
         {
             this.SetAppDomainPolicy(domainPolicy);
         }
     }
 }
Ejemplo n.º 20
0
		private void RunDomainManagerPostInitialization(AppDomainManager domainManager)
		{
			HostExecutionContextManager arg_06_0 = domainManager.HostExecutionContextManager;
			if (this.IsLegacyCasPolicyEnabled)
			{
				HostSecurityManager hostSecurityManager = domainManager.HostSecurityManager;
				if (hostSecurityManager != null && (hostSecurityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel)
				{
					PolicyLevel domainPolicy = hostSecurityManager.DomainPolicy;
					if (domainPolicy != null)
					{
						this.SetAppDomainPolicy(domainPolicy);
					}
				}
			}
		}
Ejemplo n.º 21
0
		private void CreateAppDomainManager()
		{
			AppDomainSetup arg_06_0 = this.FusionStore;
			string text;
			string text2;
			this.GetAppDomainManagerType(out text, out text2);
			if (text != null && text2 != null)
			{
				try
				{
					new PermissionSet(PermissionState.Unrestricted).Assert();
					this._domainManager = (this.CreateInstanceAndUnwrap(text, text2) as AppDomainManager);
					CodeAccessPermission.RevertAssert();
				}
				catch (FileNotFoundException inner)
				{
					throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), inner);
				}
				catch (SecurityException inner2)
				{
					throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), inner2);
				}
				catch (TypeLoadException inner3)
				{
					throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), inner3);
				}
				if (this._domainManager == null)
				{
					throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"));
				}
				this.FusionStore.AppDomainManagerAssembly = text;
				this.FusionStore.AppDomainManagerType = text2;
				bool flag = this._domainManager.GetType() != typeof(AppDomainManager) && !this.DisableFusionUpdatesFromADManager();
				AppDomainSetup oldInfo = null;
				if (flag)
				{
					oldInfo = new AppDomainSetup(this.FusionStore, true);
				}
				this._domainManager.InitializeNewDomain(this.FusionStore);
				if (flag)
				{
					this.SetupFusionStore(this._FusionStore, oldInfo);
				}
				AppDomainManagerInitializationOptions initializationFlags = this._domainManager.InitializationFlags;
				if ((initializationFlags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
				{
					this._domainManager.RegisterWithHost();
				}
			}
			this.InitializeCompatibilityFlags();
		}
Ejemplo n.º 22
0
 public virtual AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
 {
     return(AppDomainManager.CreateDomainHelper(friendlyName, securityInfo, appDomainInfo));
 }
Ejemplo n.º 23
0
 private void SetDomainManager(System.Security.Policy.Evidence providedSecurityInfo, System.Security.Policy.Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor, bool publishAppDomain)
 {
     string domainManagerAssemblyName = nGetDomainManagerAsm();
     string domainManagerTypeName = nGetDomainManagerType();
     if ((domainManagerAssemblyName != null) && (domainManagerTypeName != null))
     {
         this._domainManager = this.CreateDomainManager(domainManagerAssemblyName, domainManagerTypeName);
     }
     AppDomainSetup fusionStore = this.FusionStore;
     if (this._domainManager != null)
     {
         this._domainManager.InitializeNewDomain(fusionStore);
         if ((this._domainManager.InitializationFlags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
         {
             this._domainManager.nRegisterWithHost();
         }
     }
     if (fusionStore.ActivationArguments != null)
     {
         System.ActivationContext activationContext = null;
         System.ApplicationIdentity applicationIdentity = null;
         string[] activationData = null;
         CmsUtils.CreateActivationContext(fusionStore.ActivationArguments.ApplicationFullName, fusionStore.ActivationArguments.ApplicationManifestPaths, fusionStore.ActivationArguments.UseFusionActivationContext, out applicationIdentity, out activationContext);
         activationData = fusionStore.ActivationArguments.ActivationData;
         providedSecurityInfo = CmsUtils.MergeApplicationEvidence(providedSecurityInfo, applicationIdentity, activationContext, activationData, fusionStore.ApplicationTrust);
         this.SetupApplicationHelper(providedSecurityInfo, creatorsSecurityInfo, applicationIdentity, activationContext, activationData);
     }
     else
     {
         System.Security.Policy.ApplicationTrust applicationTrust = fusionStore.ApplicationTrust;
         if (applicationTrust != null)
         {
             this.SetupDomainSecurityForApplication(applicationTrust.ApplicationIdentity, applicationTrust);
         }
     }
     System.Security.Policy.Evidence inputEvidence = (providedSecurityInfo != null) ? providedSecurityInfo : creatorsSecurityInfo;
     if (this._domainManager != null)
     {
         System.Security.HostSecurityManager hostSecurityManager = this._domainManager.HostSecurityManager;
         if (hostSecurityManager != null)
         {
             nSetHostSecurityManagerFlags(hostSecurityManager.Flags);
             if ((hostSecurityManager.Flags & HostSecurityManagerOptions.HostAppDomainEvidence) == HostSecurityManagerOptions.HostAppDomainEvidence)
             {
                 inputEvidence = hostSecurityManager.ProvideAppDomainEvidence(inputEvidence);
             }
         }
     }
     this._SecurityIdentity = inputEvidence;
     this.nSetupDomainSecurity(inputEvidence, parentSecurityDescriptor, publishAppDomain);
     if (this._domainManager != null)
     {
         this.RunDomainManagerPostInitialization(this._domainManager);
     }
 }
Ejemplo n.º 24
0
        private void CreateAppDomainManager()
        {
            Contract.Assert(_domainManager == null, "_domainManager == null");

            AppDomainSetup adSetup = FusionStore;
#if FEATURE_VERSIONING
            String trustedPlatformAssemblies = (String)(GetData("TRUSTED_PLATFORM_ASSEMBLIES"));
            if (trustedPlatformAssemblies != null)
            {
                String platformResourceRoots = (String)(GetData("PLATFORM_RESOURCE_ROOTS"));
                if (platformResourceRoots == null)
                {
                    platformResourceRoots = String.Empty;
                }

                String appPaths = (String)(GetData("APP_PATHS"));
                if (appPaths == null)
                {
                    appPaths = String.Empty;
                }

                String appNiPaths = (String)(GetData("APP_NI_PATHS"));
                if (appNiPaths == null)
                {
                    appNiPaths = String.Empty;
                }

                String appLocalWinMD = (String)(GetData("APP_LOCAL_WINMETADATA"));
                if (appLocalWinMD == null)
                {
                    appLocalWinMD = String.Empty;
                }
                SetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPaths, appNiPaths, appLocalWinMD);
            }
#endif // FEATURE_VERSIONING

            string domainManagerAssembly;
            string domainManagerType;
            GetAppDomainManagerType(out domainManagerAssembly, out domainManagerType);

            if (domainManagerAssembly != null && domainManagerType != null)
            {
                try
                {
                    new PermissionSet(PermissionState.Unrestricted).Assert();
                    _domainManager = CreateInstanceAndUnwrap(domainManagerAssembly, domainManagerType) as AppDomainManager;
                    CodeAccessPermission.RevertAssert();
                }
                catch (FileNotFoundException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }
                catch (SecurityException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }
                catch (TypeLoadException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }

                if (_domainManager == null)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"));
                }

                // If this domain was not created by a managed call to CreateDomain, then the AppDomainSetup
                // will not have the correct values for the AppDomainManager set.
                FusionStore.AppDomainManagerAssembly = domainManagerAssembly;
                FusionStore.AppDomainManagerType = domainManagerType;

                bool notifyFusion = _domainManager.GetType() != typeof(System.AppDomainManager) && !DisableFusionUpdatesFromADManager();



                AppDomainSetup FusionStoreOld = null;
                if (notifyFusion)
                    FusionStoreOld = new AppDomainSetup(FusionStore, true);

                // Initialize the AppDomainMAnager and register the instance with the native host if requested
                _domainManager.InitializeNewDomain(FusionStore);

                if (notifyFusion)
                    SetupFusionStore(_FusionStore, FusionStoreOld); // Notify Fusion about the changes the user implementation of InitializeNewDomain may have made to the FusionStore object.
                                
#if FEATURE_APPDOMAINMANAGER_INITOPTIONS                
                AppDomainManagerInitializationOptions flags = _domainManager.InitializationFlags;
                if ((flags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
                {
                    _domainManager.RegisterWithHost();
                }
#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
            }

            InitializeCompatibilityFlags();       
        }
Ejemplo n.º 25
0
        private void CreateAppDomainManager()
        {
            Contract.Assert(_domainManager == null, "_domainManager == null");

            AppDomainSetup adSetup = FusionStore;
#if FEATURE_VERSIONING
            if (String.IsNullOrEmpty(adSetup.GetUnsecureManifestFilePath()))
            {
                String trustedPlatformAssemblies = (String)(GetData("TRUSTED_PLATFORM_ASSEMBLIES"));
                if (trustedPlatformAssemblies != null)
                {
                    String platformResourceRoots = (String)(GetData("PLATFORM_RESOURCE_ROOTS"));
                    if (platformResourceRoots == null)
                    {
                        platformResourceRoots = String.Empty;
                    }

                    String appPaths = (String)(GetData("APP_PATHS"));
                    if (appPaths == null)
                    {
                        appPaths = String.Empty;
                    }

                    String appNiPaths = (String)(GetData("APP_NI_PATHS"));
                    if (appNiPaths == null)
                    {
                        appNiPaths = String.Empty;
                    }
                    SetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPaths, appNiPaths);
                }
            } else
            {
                // Chicken-Egg problem: At this point, security is not yet fully up.
                // We need this information to power up the manifest to enable security.
                String manifestFilePath = adSetup.GetUnsecureManifestFilePath();
                bool fIsAssemblyPath = false;
                String applicationBase = adSetup.GetUnsecureApplicationBase();
                String applicationName = adSetup.ApplicationName;

                if ((manifestFilePath == null) && (applicationBase != null) && (applicationName != null))
                {
                    manifestFilePath = Path.Combine(applicationBase, applicationName);
                    fIsAssemblyPath = true;
                }
                
                SetupManifest(manifestFilePath, fIsAssemblyPath);
            }
#endif // FEATURE_VERSIONING

            string domainManagerAssembly;
            string domainManagerType;
            GetAppDomainManagerType(out domainManagerAssembly, out domainManagerType);

            if (domainManagerAssembly != null && domainManagerType != null)
            {
                try
                {
                    new PermissionSet(PermissionState.Unrestricted).Assert();
                    _domainManager = CreateInstanceAndUnwrap(domainManagerAssembly, domainManagerType) as AppDomainManager;
                    CodeAccessPermission.RevertAssert();
                }
                catch (FileNotFoundException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }
                catch (SecurityException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }
                catch (TypeLoadException e)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e);
                }

                if (_domainManager == null)
                {
                    throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"));
                }

                // If this domain was not created by a managed call to CreateDomain, then the AppDomainSetup
                // will not have the correct values for the AppDomainManager set.
                FusionStore.AppDomainManagerAssembly = domainManagerAssembly;
                FusionStore.AppDomainManagerType = domainManagerType;

                bool notifyFusion = _domainManager.GetType() != typeof(System.AppDomainManager) && !DisableFusionUpdatesFromADManager();



                AppDomainSetup FusionStoreOld = null;
                if (notifyFusion)
                    FusionStoreOld = new AppDomainSetup(FusionStore, true);

                // Initialize the AppDomainMAnager and register the instance with the native host if requested
                _domainManager.InitializeNewDomain(FusionStore);

                if (notifyFusion)
                    SetupFusionStore(_FusionStore, FusionStoreOld); // Notify Fusion about the changes the user implementation of InitializeNewDomain may have made to the FusionStore object.
                                
#if FEATURE_APPDOMAINMANAGER_INITOPTIONS                
                AppDomainManagerInitializationOptions flags = _domainManager.InitializationFlags;
                if ((flags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
                {
                    _domainManager.RegisterWithHost();
                }
#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
            }

            InitializeCompatibilityFlags();       
        }
Ejemplo n.º 26
0
		public void JaggedArrays ()
		{
			// transparent type
			FrameworkElement [][] fe = new FrameworkElement [0][];
			Assert.IsNotNull (fe, "FrameworkElement[,]");

			// critical type
			AppDomainManager [][] adm = new AppDomainManager [0][];
			Assert.IsNotNull (adm, "AppDomainManager[,]");
		}
Ejemplo n.º 27
0
        [System.Security.SecurityCritical]  // auto-generated
        private void RunDomainManagerPostInitialization (AppDomainManager domainManager)
        {
            // force creation of the HostExecutionContextManager for the current AppDomain
            HostExecutionContextManager contextManager = domainManager.HostExecutionContextManager;

            if (IsLegacyCasPolicyEnabled)
            {
#pragma warning disable 618
                HostSecurityManager securityManager = domainManager.HostSecurityManager;
                if (securityManager != null)
                {
                    if ((securityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel)
                    {
                        // set AppDomain policy if specified
                        PolicyLevel level = securityManager.DomainPolicy;
                        if (level != null)
                            SetAppDomainPolicy(level);
                    }
                }
#pragma warning restore 618
            }
        }
Ejemplo n.º 28
0
        // Called for every AppDomain (including the default domain) to initialize 
        // the AppDomainManager instance and security of the AppDomain.
        private void SetDomainManager (Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor, bool publishAppDomain) {

            // Create the AppDomainManager for the AppDomain if specified.
            string domainManagerAssemblyName = nGetDomainManagerAsm ();
            string domainManagerTypeName = nGetDomainManagerType ();

            if (domainManagerAssemblyName != null && domainManagerTypeName != null)
                _domainManager = CreateDomainManager(domainManagerAssemblyName, domainManagerTypeName);

            AppDomainSetup adSetup = FusionStore;
            // Call AppDomainManager initialization -- runs host custom code.
            if (_domainManager != null) {
                // Call InitializeNewDomain and register the AppDomainManager with the host if needed.
                _domainManager.InitializeNewDomain(adSetup);
                AppDomainManagerInitializationOptions flags = _domainManager.InitializationFlags;
                if ((flags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
                    _domainManager.nRegisterWithHost();
            }


            // Set the new evidence to the default loader behavior.
            Evidence newAppDomainEvidence = (providedSecurityInfo != null ? providedSecurityInfo : creatorsSecurityInfo);
            if (_domainManager != null) {
                // Give the host a chance to alter the AppDomain evidence
                HostSecurityManager securityManager = _domainManager.HostSecurityManager;
                if (securityManager != null) {
                    nSetHostSecurityManagerFlags (securityManager.Flags);
                    if ((securityManager.Flags & HostSecurityManagerOptions.HostAppDomainEvidence) == HostSecurityManagerOptions.HostAppDomainEvidence)
                        newAppDomainEvidence = securityManager.ProvideAppDomainEvidence(newAppDomainEvidence);
                }
            }

            // Set the evidence on the managed side
            _SecurityIdentity = newAppDomainEvidence;

            // Set the evidence of the AppDomain in the VM.
            // Also, now that the initialization is complete, signal that to the security system.
            // Finish the AppDomain initialization and resolve the policy for the AppDomain evidence.
            nSetupDomainSecurity(newAppDomainEvidence, parentSecurityDescriptor, publishAppDomain);

            // The AppDomain is now resolved. Go ahead and set the PolicyLevel
            // from the HostSecurityManager if specified.
            if (_domainManager != null)
                RunDomainManagerPostInitialization(_domainManager);
        }