Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / AppDomainManager.cs / 1305376 / AppDomainManager.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // An AppDomainManager gives a hosting application the chance to // participate in the creation and control the settings of new AppDomains. // namespace System { using System.Collections; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Security.Policy; using System.Threading; #if FEATURE_CLICKONCE using System.Runtime.Hosting; #endif using System.Runtime.Versioning; using System.Runtime.InteropServices; using System.Diagnostics.Contracts; #if FEATURE_APPDOMAINMANAGER_INITOPTIONS [Flags] [System.Runtime.InteropServices.ComVisible(true)] public enum AppDomainManagerInitializationOptions { None = 0x0000, RegisterWithHost = 0x0001 } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS #if FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated_required [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class AppDomainManager : MarshalByRefObject { #if false } #endif // false #else // FEATURE_REMOTING [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class AppDomainManager { #endif // FEATURE_REMOTING public AppDomainManager () {} #if FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated public virtual AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) { return CreateDomainHelper(friendlyName, securityInfo, appDomainInfo); } [System.Security.SecurityCritical] // auto-generated_required [SecurityPermissionAttribute(SecurityAction.Demand, ControlAppDomain = true)] 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; } } return AppDomain.nCreateDomain(friendlyName, appDomainInfo, securityInfo, securityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : null, AppDomain.CurrentDomain.GetSecurityDescriptor()); } #endif // FEATURE_REMOTING [System.Security.SecurityCritical] public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo) { // By default, InitializeNewDomain does nothing. AppDomain.CreateAppDomainManager relies on this fact. } #if FEATURE_APPDOMAINMANAGER_INITOPTIONS private AppDomainManagerInitializationOptions m_flags = AppDomainManagerInitializationOptions.None; public AppDomainManagerInitializationOptions InitializationFlags { get { return m_flags; } set { m_flags = value; } } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS #if !FEATURE_PAL && FEATURE_CLICKONCE private ApplicationActivator m_appActivator = null; public virtual ApplicationActivator ApplicationActivator { get { if (m_appActivator == null) m_appActivator = new ApplicationActivator(); return m_appActivator; } } #endif //#if !FEATURE_PAL && FEATURE_CLICKONCE #if FEATURE_CAS_POLICY public virtual HostSecurityManager HostSecurityManager { get { return null; } } public virtual HostExecutionContextManager HostExecutionContextManager { get { // By default, the AppDomainManager returns the HostExecutionContextManager. return HostExecutionContextManager.GetInternalHostExecutionContextManager(); } } #endif // FEATURE_CAS_POLICY #if !FEATURE_CORECLR [ResourceExposure(ResourceScope.None)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] private static extern void GetEntryAssembly(ObjectHandleOnStack retAssembly); private Assembly m_entryAssembly = null; public virtual Assembly EntryAssembly { [System.Security.SecurityCritical] // auto-generated get { // The default AppDomainManager sets the EntryAssembly depending on whether the // AppDomain is a manifest application domain or not. In the first case, we parse // the application manifest to find out the entry point assembly and return that assembly. // In the second case, we maintain the old behavior by calling GetEntryAssembly(). if (m_entryAssembly == null) { #if !FEATURE_PAL && FEATURE_CLICKONCE AppDomain domain = AppDomain.CurrentDomain; if (domain.IsDefaultAppDomain() && domain.ActivationContext != null) { ManifestRunner runner = new ManifestRunner(domain, domain.ActivationContext); m_entryAssembly = runner.EntryAssembly; } else #endif //#if !FEATURE_PAL && FEATURE_CLICKONCE { RuntimeAssembly entryAssembly = null; GetEntryAssembly(JitHelpers.GetObjectHandleOnStack(ref entryAssembly)); m_entryAssembly = entryAssembly; } } return m_entryAssembly; } } #endif // FEATURE_CORECLR internal static AppDomainManager CurrentAppDomainManager { [System.Security.SecurityCritical] // auto-generated get { return AppDomain.CurrentDomain.DomainManager; } } public virtual bool CheckSecuritySettings (SecurityState state) { return false; } #if FEATURE_APPDOMAINMANAGER_INITOPTIONS [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool HasHost(); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [SecurityCritical] [SuppressUnmanagedCodeSecurity] private static extern void RegisterWithHost(IntPtr appDomainManager); internal void RegisterWithHost() { if (HasHost()) { IntPtr punkAppDomainManager = IntPtr.Zero; RuntimeHelpers.PrepareConstrainedRegions(); try { punkAppDomainManager = Marshal.GetIUnknownForObject(this); RegisterWithHost(punkAppDomainManager); } finally { if (!punkAppDomainManager.IsNull()) { Marshal.Release(punkAppDomainManager); } } } } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // An AppDomainManager gives a hosting application the chance to // participate in the creation and control the settings of new AppDomains. // namespace System { using System.Collections; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Security.Policy; using System.Threading; #if FEATURE_CLICKONCE using System.Runtime.Hosting; #endif using System.Runtime.Versioning; using System.Runtime.InteropServices; using System.Diagnostics.Contracts; #if FEATURE_APPDOMAINMANAGER_INITOPTIONS [Flags] [System.Runtime.InteropServices.ComVisible(true)] public enum AppDomainManagerInitializationOptions { None = 0x0000, RegisterWithHost = 0x0001 } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS #if FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated_required [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class AppDomainManager : MarshalByRefObject { #if false } #endif // false #else // FEATURE_REMOTING [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class AppDomainManager { #endif // FEATURE_REMOTING public AppDomainManager () {} #if FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated public virtual AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) { return CreateDomainHelper(friendlyName, securityInfo, appDomainInfo); } [System.Security.SecurityCritical] // auto-generated_required [SecurityPermissionAttribute(SecurityAction.Demand, ControlAppDomain = true)] 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; } } return AppDomain.nCreateDomain(friendlyName, appDomainInfo, securityInfo, securityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : null, AppDomain.CurrentDomain.GetSecurityDescriptor()); } #endif // FEATURE_REMOTING [System.Security.SecurityCritical] public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo) { // By default, InitializeNewDomain does nothing. AppDomain.CreateAppDomainManager relies on this fact. } #if FEATURE_APPDOMAINMANAGER_INITOPTIONS private AppDomainManagerInitializationOptions m_flags = AppDomainManagerInitializationOptions.None; public AppDomainManagerInitializationOptions InitializationFlags { get { return m_flags; } set { m_flags = value; } } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS #if !FEATURE_PAL && FEATURE_CLICKONCE private ApplicationActivator m_appActivator = null; public virtual ApplicationActivator ApplicationActivator { get { if (m_appActivator == null) m_appActivator = new ApplicationActivator(); return m_appActivator; } } #endif //#if !FEATURE_PAL && FEATURE_CLICKONCE #if FEATURE_CAS_POLICY public virtual HostSecurityManager HostSecurityManager { get { return null; } } public virtual HostExecutionContextManager HostExecutionContextManager { get { // By default, the AppDomainManager returns the HostExecutionContextManager. return HostExecutionContextManager.GetInternalHostExecutionContextManager(); } } #endif // FEATURE_CAS_POLICY #if !FEATURE_CORECLR [ResourceExposure(ResourceScope.None)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] private static extern void GetEntryAssembly(ObjectHandleOnStack retAssembly); private Assembly m_entryAssembly = null; public virtual Assembly EntryAssembly { [System.Security.SecurityCritical] // auto-generated get { // The default AppDomainManager sets the EntryAssembly depending on whether the // AppDomain is a manifest application domain or not. In the first case, we parse // the application manifest to find out the entry point assembly and return that assembly. // In the second case, we maintain the old behavior by calling GetEntryAssembly(). if (m_entryAssembly == null) { #if !FEATURE_PAL && FEATURE_CLICKONCE AppDomain domain = AppDomain.CurrentDomain; if (domain.IsDefaultAppDomain() && domain.ActivationContext != null) { ManifestRunner runner = new ManifestRunner(domain, domain.ActivationContext); m_entryAssembly = runner.EntryAssembly; } else #endif //#if !FEATURE_PAL && FEATURE_CLICKONCE { RuntimeAssembly entryAssembly = null; GetEntryAssembly(JitHelpers.GetObjectHandleOnStack(ref entryAssembly)); m_entryAssembly = entryAssembly; } } return m_entryAssembly; } } #endif // FEATURE_CORECLR internal static AppDomainManager CurrentAppDomainManager { [System.Security.SecurityCritical] // auto-generated get { return AppDomain.CurrentDomain.DomainManager; } } public virtual bool CheckSecuritySettings (SecurityState state) { return false; } #if FEATURE_APPDOMAINMANAGER_INITOPTIONS [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool HasHost(); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [SecurityCritical] [SuppressUnmanagedCodeSecurity] private static extern void RegisterWithHost(IntPtr appDomainManager); internal void RegisterWithHost() { if (HasHost()) { IntPtr punkAppDomainManager = IntPtr.Zero; RuntimeHelpers.PrepareConstrainedRegions(); try { punkAppDomainManager = Marshal.GetIUnknownForObject(this); RegisterWithHost(punkAppDomainManager); } finally { if (!punkAppDomainManager.IsNull()) { Marshal.Release(punkAppDomainManager); } } } } #endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlNodeReader.cs
- SqlDataAdapter.cs
- PropertyCondition.cs
- DbConnectionPoolGroup.cs
- RectangleF.cs
- StateInitializationDesigner.cs
- TextSpan.cs
- CommandField.cs
- SqlEnums.cs
- ComponentResourceManager.cs
- IdentityNotMappedException.cs
- sqlser.cs
- Merger.cs
- ReflectTypeDescriptionProvider.cs
- ItemAutomationPeer.cs
- PreviewPageInfo.cs
- GlobalEventManager.cs
- InputBinder.cs
- WorkflowServiceNamespace.cs
- FloaterParaClient.cs
- OverloadGroupAttribute.cs
- AxisAngleRotation3D.cs
- ClientTarget.cs
- Claim.cs
- AppSettingsExpressionBuilder.cs
- updateconfighost.cs
- TreeNodeCollection.cs
- SmtpMail.cs
- DataFormats.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- SQLChars.cs
- Int32RectConverter.cs
- XmlSchemaValidationException.cs
- XhtmlCssHandler.cs
- DataTemplateKey.cs
- ConsumerConnectionPoint.cs
- UserPreferenceChangedEventArgs.cs
- Facet.cs
- XmlSchemaExporter.cs
- ContextProperty.cs
- StateWorkerRequest.cs
- ListMarkerSourceInfo.cs
- ExternalException.cs
- MatrixUtil.cs
- SrgsRulesCollection.cs
- FakeModelPropertyImpl.cs
- complextypematerializer.cs
- CryptoApi.cs
- ServiceDescriptions.cs
- SspiSecurityToken.cs
- DynamicMethod.cs
- ProcessHostConfigUtils.cs
- AdornerHitTestResult.cs
- MarkupProperty.cs
- GiveFeedbackEventArgs.cs
- CanonicalXml.cs
- AudienceUriMode.cs
- FloatUtil.cs
- SystemIPv4InterfaceProperties.cs
- MethodBuilderInstantiation.cs
- ImageDrawing.cs
- MailDefinition.cs
- DupHandleConnectionReader.cs
- XmlSchemaProviderAttribute.cs
- TransformerInfoCollection.cs
- QuaternionAnimationBase.cs
- ParameterRetriever.cs
- xmlglyphRunInfo.cs
- PropertyMapper.cs
- BindingExpressionBase.cs
- DataGridRowHeaderAutomationPeer.cs
- ColumnTypeConverter.cs
- ContainerVisual.cs
- LoadedOrUnloadedOperation.cs
- SequentialOutput.cs
- DefaultProxySection.cs
- InstanceLockedException.cs
- TargetInvocationException.cs
- CryptographicAttribute.cs
- ContainerFilterService.cs
- DataGridViewRowsAddedEventArgs.cs
- ConnectionsZone.cs
- KnownBoxes.cs
- StorageComplexTypeMapping.cs
- PersistNameAttribute.cs
- StructuredTypeEmitter.cs
- DispatchChannelSink.cs
- DataGridViewBindingCompleteEventArgs.cs
- File.cs
- BaseProcessor.cs
- OleDbWrapper.cs
- EventSourceCreationData.cs
- SqlDataAdapter.cs
- LiteralLink.cs
- SqlConnectionManager.cs
- ContentDisposition.cs
- LazyTextWriterCreator.cs
- sqlinternaltransaction.cs
- NamespaceEmitter.cs
- SQLBytesStorage.cs