31 [ComDefaultInterface(typeof(_AppDomain))]
36 private enum APPX_FLAGS
38 APPX_FLAGS_INITIALIZED = 0x1,
39 APPX_FLAGS_APPX_MODEL = 0x2,
40 APPX_FLAGS_APPX_DESIGN_MODE = 0x4,
41 APPX_FLAGS_APPX_NGEN = 0x8,
42 APPX_FLAGS_APPX_MASK = 0xE,
43 APPX_FLAGS_API_CHECK = 0x10
46 private class NamespaceResolverForIntrospection
52 _packageGraphFilePaths = packageGraphFilePaths;
59 foreach (
string item
in enumerable)
67 private class EvidenceCollection
69 public Evidence ProvidedSecurityInfo;
71 public Evidence CreatorsSecurityInfo;
87 if (publicKeyToken ==
null)
91 if (publicKeyToken2 ==
null)
95 if (publicKeyToken.Length < publicKeyToken2.Length)
99 if (publicKeyToken.Length > publicKeyToken2.Length)
103 for (
int i = 0; i < publicKeyToken.Length; i++)
105 byte b = publicKeyToken[i];
106 byte b2 = publicKeyToken2[i];
129 private object[] _Policies;
140 private Context _DefaultContext;
150 private DomainSpecificRemotingData _RemotingData;
158 private string[] _aptcaVisibleAssemblies;
162 private EventHandler<FirstChanceExceptionEventArgs> _firstChanceException;
168 private bool _HasSetPolicy;
170 private bool _IsFastFullTrustDomain;
172 private bool _compatFlagsInitialized;
174 internal const string TargetFrameworkNameAppCompatSetting =
"TargetFrameworkName";
176 private static APPX_FLAGS s_flags;
178 internal const int DefaultADID = 1;
180 private static APPX_FLAGS Flags
182 [SecuritySafeCritical]
185 if (s_flags == (APPX_FLAGS)0)
187 s_flags = nGetAppXFlags();
193 internal static bool ProfileAPICheck
195 [SecuritySafeCritical]
198 return (Flags & APPX_FLAGS.APPX_FLAGS_API_CHECK) != (APPX_FLAGS)0;
202 internal static bool IsAppXNGen
204 [SecuritySafeCritical]
207 return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_NGEN) != (APPX_FLAGS)0;
211 internal string[] PartialTrustVisibleAssemblies
215 return _aptcaVisibleAssemblies;
217 [SecuritySafeCritical]
220 _aptcaVisibleAssemblies = value;
221 string canonicalConditionalAptcaList =
null;
225 for (
int i = 0; i < value.Length; i++)
227 if (value[i] !=
null)
229 stringBuilder.
Append(value[i].ToUpperInvariant());
230 if (i != value.Length - 1)
232 stringBuilder.
Append(
';');
236 canonicalConditionalAptcaList = StringBuilderCache.GetStringAndRelease(stringBuilder);
238 SetCanonicalConditionalAptcaList(canonicalConditionalAptcaList);
249 return _domainManager;
260 if (domainManager !=
null)
264 if (hostSecurityManager ==
null)
268 return hostSecurityManager;
281 [SecuritySafeCritical]
285 return EvidenceNoDemand;
294 if (_SecurityIdentity ==
null)
300 return new Evidence(
new AppDomainEvidenceFactory(
this));
302 return _SecurityIdentity.
Clone();
306 internal Evidence InternalEvidence => _SecurityIdentity;
313 [SecuritySafeCritical]
316 return nGetFriendlyName();
339 if (shadowCopyFiles !=
null &&
string.Compare(shadowCopyFiles,
"true",
StringComparison.OrdinalIgnoreCase) == 0)
354 return _activationContext;
365 return _applicationIdentity;
376 if (_applicationTrust ==
null && _IsFastFullTrustDomain)
380 return _applicationTrust;
389 [SecuritySafeCritical]
392 string dynamicDir = GetDynamicDir();
393 if (dynamicDir !=
null)
401 internal DomainSpecificRemotingData RemotingData
405 if (_RemotingData ==
null)
407 CreateRemotingData();
409 return _RemotingData;
413 internal AppDomainSetup FusionStore => _FusionStore;
419 if (_LocalStore !=
null)
441 GetGrantSet(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref o));
455 [SecuritySafeCritical]
459 GetGrantSet(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref o));
460 return o?.IsUnrestricted() ??
true;
471 if (!_IsFastFullTrustDomain)
473 return _applicationTrust !=
null;
479 internal bool IsLegacyCasPolicyEnabled
481 [SecuritySafeCritical]
484 return GetIsLegacyCasPolicyEnabled(GetNativeHandle());
492 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
508 return nMonitoringIsEnabled();
529 long num = nGetTotalProcessorTime();
546 long num = nGetTotalAllocatedMemorySize();
564 long num = nGetLastSurvivedMemorySize();
581 long num = nGetLastSurvivedProcessMemorySize();
591 [method: SecurityCritical]
658 [method: SecurityCritical]
664 [SecuritySafeCritical]
688 [SecuritySafeCritical]
745 _firstChanceException = (EventHandler<FirstChanceExceptionEventArgs>)
Delegate.
Combine(_firstChanceException, value);
754 _firstChanceException = (EventHandler<FirstChanceExceptionEventArgs>)
Delegate.
Remove(_firstChanceException, value);
761 [SuppressUnmanagedCodeSecurity]
763 private static extern bool DisableFusionUpdatesFromADManager(AppDomainHandle domain);
767 [SuppressUnmanagedCodeSecurity]
769 private static extern APPX_FLAGS nGetAppXFlags();
773 [SuppressUnmanagedCodeSecurity]
774 private static extern void GetAppDomainManagerType(AppDomainHandle domain, StringHandleOnStack retAssembly, StringHandleOnStack retType);
778 [SuppressUnmanagedCodeSecurity]
779 private static extern void SetAppDomainManagerType(AppDomainHandle domain,
string assembly,
string type);
787 [SuppressUnmanagedCodeSecurity]
788 private static extern void SetSecurityHomogeneousFlag(AppDomainHandle domain, [MarshalAs(
UnmanagedType.Bool)]
bool runtimeSuppliedHomogenousGrantSet);
792 [SuppressUnmanagedCodeSecurity]
793 private static extern void SetLegacyCasPolicyEnabled(AppDomainHandle domain);
796 private void SetLegacyCasPolicyEnabled()
798 SetLegacyCasPolicyEnabled(GetNativeHandle());
801 internal AppDomainHandle GetNativeHandle()
803 if (_pDomain.IsNull())
805 throw new InvalidOperationException(Environment.GetResourceString(
"Argument_InvalidHandle"));
807 return new AppDomainHandle(_pDomain);
810 [SecuritySafeCritical]
811 private void CreateAppDomainManager()
813 AppDomainSetup fusionStore = FusionStore;
814 GetAppDomainManagerType(out
string assembly, out
string type);
815 if (assembly !=
null && type !=
null)
825 throw new TypeLoadException(Environment.GetResourceString(
"Argument_NoDomainManager"), inner);
829 throw new TypeLoadException(Environment.GetResourceString(
"Argument_NoDomainManager"), inner2);
831 catch (TypeLoadException inner3)
833 throw new TypeLoadException(Environment.GetResourceString(
"Argument_NoDomainManager"), inner3);
835 if (_domainManager ==
null)
837 throw new TypeLoadException(Environment.GetResourceString(
"Argument_NoDomainManager"));
839 FusionStore.AppDomainManagerAssembly = assembly;
840 FusionStore.AppDomainManagerType = type;
841 bool flag = _domainManager.GetType() != typeof(AppDomainManager) && !DisableFusionUpdatesFromADManager();
842 AppDomainSetup oldInfo =
null;
845 oldInfo =
new AppDomainSetup(FusionStore, copyDomainBoundData:
true);
850 SetupFusionStore(_FusionStore, oldInfo);
855 _domainManager.RegisterWithHost();
858 InitializeCompatibilityFlags();
861 private void InitializeCompatibilityFlags()
863 AppDomainSetup fusionStore = FusionStore;
864 if (fusionStore.GetCompatibilityFlags() !=
null)
868 _compatFlagsInitialized =
true;
869 CompatibilitySwitches.InitializeSwitches();
872 [SecuritySafeCritical]
873 internal string GetTargetFrameworkName()
876 if (text ==
null &&
IsDefaultAppDomain() && !_FusionStore.CheckedForTargetFrameworkName)
879 if (entryAssembly !=
null)
882 if (array !=
null && array.Length != 0)
884 text = array[0].FrameworkName;
888 _FusionStore.CheckedForTargetFrameworkName =
true;
893 [SecuritySafeCritical]
894 private void SetTargetFrameworkName(
string targetFrameworkName)
896 if (!_FusionStore.CheckedForTargetFrameworkName)
899 _FusionStore.CheckedForTargetFrameworkName =
true;
903 [SecuritySafeCritical]
904 internal bool DisableFusionUpdatesFromADManager()
906 return DisableFusionUpdatesFromADManager(GetNativeHandle());
909 [SecuritySafeCritical]
910 internal static bool IsAppXModel()
912 return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_MODEL) != (APPX_FLAGS)0;
915 [SecuritySafeCritical]
916 internal static bool IsAppXDesignMode()
918 return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_MASK) == (APPX_FLAGS.APPX_FLAGS_APPX_MODEL | APPX_FLAGS.APPX_FLAGS_APPX_DESIGN_MODE);
921 [SecuritySafeCritical]
922 internal static void CheckLoadFromSupported()
926 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"Assembly.LoadFrom"));
930 [SecuritySafeCritical]
931 internal static void CheckLoadFileSupported()
935 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"Assembly.LoadFile"));
939 [SecuritySafeCritical]
940 internal static void CheckReflectionOnlyLoadSupported()
944 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"Assembly.ReflectionOnlyLoad"));
948 [SecuritySafeCritical]
949 internal static void CheckLoadWithPartialNameSupported(StackCrawlMark stackMark)
953 RuntimeAssembly executingAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
954 if (!(executingAssembly !=
null) || !executingAssembly.IsFrameworkAssembly())
956 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"Assembly.LoadWithPartialName"));
961 [SecuritySafeCritical]
962 internal static void CheckDefinePInvokeSupported()
966 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"DefinePInvokeMethod"));
970 [SecuritySafeCritical]
971 internal static void CheckLoadByteArraySupported()
975 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"Assembly.Load(byte[], ...)"));
979 [SecuritySafeCritical]
980 internal static void CheckCreateDomainSupported()
982 if (IsAppXModel() && !IsAppXDesignMode())
984 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_AppX",
"AppDomain.CreateDomain"));
988 [SecuritySafeCritical]
989 internal void GetAppDomainManagerType(out
string assembly, out
string type)
993 GetAppDomainManagerType(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref s), JitHelpers.GetStringHandleOnStack(ref s2));
998 [SecuritySafeCritical]
999 private void SetAppDomainManagerType(
string assembly,
string type)
1001 SetAppDomainManagerType(GetNativeHandle(), assembly, type);
1006 [SuppressUnmanagedCodeSecurity]
1007 private static extern void SetCanonicalConditionalAptcaList(AppDomainHandle appDomain,
string canonicalList);
1010 private void SetCanonicalConditionalAptcaList(
string canonicalList)
1012 SetCanonicalConditionalAptcaList(GetNativeHandle(), canonicalList);
1015 private void SetupDefaultClickOnceDomain(
string fullName,
string[] manifestPaths,
string[] activationData)
1017 FusionStore.ActivationArguments =
new ActivationArguments(fullName, manifestPaths, activationData);
1021 private void InitializeDomainSecurity(
Evidence providedSecurityInfo,
Evidence creatorsSecurityInfo,
bool generateDefaultEvidence, IntPtr parentSecurityDescriptor,
bool publishAppDomain)
1023 AppDomainSetup fusionStore = FusionStore;
1024 if (CompatibilitySwitches.IsNetFx40LegacySecurityPolicy)
1026 SetLegacyCasPolicyEnabled();
1028 if (fusionStore.ActivationArguments !=
null)
1032 string[] array =
null;
1033 CmsUtils.CreateActivationContext(fusionStore.ActivationArguments.ApplicationFullName, fusionStore.ActivationArguments.ApplicationManifestPaths, fusionStore.ActivationArguments.UseFusionActivationContext, out applicationIdentity, out activationContext);
1034 array = fusionStore.ActivationArguments.ActivationData;
1035 providedSecurityInfo = CmsUtils.MergeApplicationEvidence(providedSecurityInfo, applicationIdentity, activationContext, array, fusionStore.ApplicationTrust);
1036 SetupApplicationHelper(providedSecurityInfo, creatorsSecurityInfo, applicationIdentity, activationContext, array);
1040 bool runtimeSuppliedHomogenousGrantSet =
false;
1042 if (applicationTrust ==
null && !IsLegacyCasPolicyEnabled)
1044 _IsFastFullTrustDomain =
true;
1045 runtimeSuppliedHomogenousGrantSet =
true;
1047 if (applicationTrust !=
null)
1049 SetupDomainSecurityForHomogeneousDomain(applicationTrust, runtimeSuppliedHomogenousGrantSet);
1051 else if (_IsFastFullTrustDomain)
1053 SetSecurityHomogeneousFlag(GetNativeHandle(), runtimeSuppliedHomogenousGrantSet);
1056 Evidence evidence = (providedSecurityInfo !=
null) ? providedSecurityInfo : creatorsSecurityInfo;
1057 if (evidence ==
null && generateDefaultEvidence)
1059 evidence =
new Evidence(
new AppDomainEvidenceFactory(
this));
1061 if (_domainManager !=
null)
1064 if (hostSecurityManager !=
null)
1066 nSetHostSecurityManagerFlags(hostSecurityManager.
Flags);
1070 if (evidence !=
null && evidence.Target ==
null)
1072 evidence.Target =
new AppDomainEvidenceFactory(
this);
1077 _SecurityIdentity = evidence;
1078 SetupDomainSecurity(evidence, parentSecurityDescriptor, publishAppDomain);
1079 if (_domainManager !=
null)
1081 RunDomainManagerPostInitialization(_domainManager);
1086 private void RunDomainManagerPostInitialization(AppDomainManager domainManager)
1089 if (!IsLegacyCasPolicyEnabled)
1097 if (domainPolicy !=
null)
1111 throw new PolicyException(Environment.GetResourceString(
"Policy_NoExecutionPermission"), -2146233320,
null);
1113 if (activationContext !=
null)
1115 SetupDomainForApplication(activationContext, activationData);
1117 SetupDomainSecurityForApplication(appIdentity, applicationTrust);
1121 private void SetupDomainForApplication(
ActivationContext activationContext,
string[] activationData)
1125 AppDomainSetup fusionStore = FusionStore;
1126 fusionStore.ActivationArguments =
new ActivationArguments(activationContext, activationData);
1127 string entryPointFullPath = CmsUtils.GetEntryPointFullPath(activationContext);
1128 if (!
string.IsNullOrEmpty(entryPointFullPath))
1130 fusionStore.SetupDefaults(entryPointFullPath);
1134 fusionStore.ApplicationBase = activationContext.ApplicationDirectory;
1136 SetupFusionStore(fusionStore,
null);
1138 activationContext.PrepareForExecution();
1139 activationContext.SetApplicationState(
ActivationContext.ApplicationState.Starting);
1140 activationContext.SetApplicationState(
ActivationContext.ApplicationState.Running);
1142 string dataDirectory = activationContext.DataDirectory;
1143 if (dataDirectory !=
null && dataDirectory.Length > 0)
1147 SetData(
"DataDirectory", dataDirectory, permission);
1148 _activationContext = activationContext;
1154 _applicationIdentity = appIdentity;
1155 SetupDomainSecurityForHomogeneousDomain(appTrust, runtimeSuppliedHomogenousGrantSet:
false);
1159 private void SetupDomainSecurityForHomogeneousDomain(
ApplicationTrust appTrust,
bool runtimeSuppliedHomogenousGrantSet)
1161 if (runtimeSuppliedHomogenousGrantSet)
1165 _applicationTrust = appTrust;
1166 SetSecurityHomogeneousFlag(GetNativeHandle(), runtimeSuppliedHomogenousGrantSet);
1169 [SecuritySafeCritical]
1170 private int ActivateApplication()
1173 return (
int)objectHandle.
Unwrap();
1176 private Assembly ResolveAssemblyForIntrospection(
object sender, ResolveEventArgs args)
1181 [SecuritySafeCritical]
1182 private void EnableResolveAssembliesForIntrospection(
string verifiedFileDirectory)
1185 string[] packageGraphFilePaths =
null;
1186 if (verifiedFileDirectory !=
null)
1188 packageGraphFilePaths =
new string[1]
1190 verifiedFileDirectory
1193 NamespaceResolverForIntrospection @
object =
new NamespaceResolverForIntrospection(packageGraphFilePaths);
1206 [SecuritySafeCritical]
1209 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1210 return InternalDefineDynamicAssembly(name, access,
null,
null,
null,
null,
null, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1223 [SecuritySafeCritical]
1226 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1227 return InternalDefineDynamicAssembly(name, access,
null,
null,
null,
null,
null, ref stackMark, assemblyAttributes,
SecurityContextSource.CurrentAssembly);
1243 [SecuritySafeCritical]
1246 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1247 return InternalDefineDynamicAssembly(name, access,
null,
null,
null,
null,
null, ref stackMark, assemblyAttributes, securityContextSource);
1260 [SecuritySafeCritical]
1263 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1264 return InternalDefineDynamicAssembly(name, access, dir,
null,
null,
null,
null, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1277 [SecuritySafeCritical]
1278 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1281 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1282 return InternalDefineDynamicAssembly(name, access,
null, evidence,
null,
null,
null, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1297 [SecuritySafeCritical]
1298 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1301 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1302 return InternalDefineDynamicAssembly(name, access,
null,
null, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1316 [SecuritySafeCritical]
1317 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of DefineDynamicAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
1320 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1321 return InternalDefineDynamicAssembly(name, access, dir, evidence,
null,
null,
null, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1337 [SecuritySafeCritical]
1338 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1341 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1342 return InternalDefineDynamicAssembly(name, access, dir,
null, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1358 [SecuritySafeCritical]
1359 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1362 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1363 return InternalDefineDynamicAssembly(name, access,
null, evidence, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1380 [SecuritySafeCritical]
1381 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. Please see http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
1384 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1385 return InternalDefineDynamicAssembly(name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1404 [SecuritySafeCritical]
1405 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1408 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1409 return InternalDefineDynamicAssembly(name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark,
null,
SecurityContextSource.CurrentAssembly);
1429 [SecuritySafeCritical]
1430 [Obsolete(
"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1433 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1434 return InternalDefineDynamicAssembly(name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark, assemblyAttributes,
SecurityContextSource.CurrentAssembly);
1450 [SecuritySafeCritical]
1453 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1454 return InternalDefineDynamicAssembly(name, access, dir,
null,
null,
null,
null, ref stackMark, assemblyAttributes,
SecurityContextSource.CurrentAssembly);
1461 return AssemblyBuilder.InternalDefineDynamicAssembly(name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, ref stackMark, assemblyAttributes, securityContextSource);
1465 [SecuritySafeCritical]
1480 if (array ==
null || array.Length == 0)
1482 return assemblyName;
1484 return nApplyPolicy(assemblyName2);
1510 if (assemblyName ==
null)
1518 internal ObjectHandle InternalCreateInstanceWithNoSecurity(
string assemblyName,
string typeName)
1552 internal ObjectHandle InternalCreateInstanceFromWithNoSecurity(
string assemblyName,
string typeName)
1643 if (assemblyName ==
null)
1704 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstance which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1711 if (assemblyName ==
null)
1715 if (securityAttributes !=
null && !IsLegacyCasPolicyEnabled)
1719 return Activator.
CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
1753 if (assemblyName ==
null)
1757 return Activator.
CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes);
1761 internal ObjectHandle InternalCreateInstanceWithNoSecurity(
string assemblyName,
string typeName,
bool ignoreCase,
BindingFlags bindingAttr,
Binder binder,
object[] args,
CultureInfo culture,
object[] activationAttributes,
Evidence securityAttributes)
1764 return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
1794 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1801 if (securityAttributes !=
null && !IsLegacyCasPolicyEnabled)
1805 return Activator.
CreateInstanceFrom(assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
1840 return Activator.
CreateInstanceFrom(assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes);
1844 internal ObjectHandle InternalCreateInstanceFromWithNoSecurity(
string assemblyName,
string typeName,
bool ignoreCase,
BindingFlags bindingAttr,
Binder binder,
object[] args,
CultureInfo culture,
object[] activationAttributes,
Evidence securityAttributes)
1847 return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
1862 [SecuritySafeCritical]
1865 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1866 return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef,
null,
null, ref stackMark, throwOnFileNotFound:
true, forIntrospection:
false, suppressSecurityChecks:
false);
1881 [SecuritySafeCritical]
1884 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1885 return RuntimeAssembly.InternalLoad(assemblyString,
null, ref stackMark, forIntrospection:
false);
1898 [SecuritySafeCritical]
1901 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1902 return RuntimeAssembly.nLoadImage(rawAssembly,
null,
null, ref stackMark, fIntrospection:
false,
SecurityContextSource.CurrentAssembly);
1916 [SecuritySafeCritical]
1919 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1920 return RuntimeAssembly.nLoadImage(rawAssembly, rawSymbolStore,
null, ref stackMark, fIntrospection:
false,
SecurityContextSource.CurrentAssembly);
1937 [SecuritySafeCritical]
1938 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
1942 if (securityEvidence !=
null && !IsLegacyCasPolicyEnabled)
1946 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1947 return RuntimeAssembly.nLoadImage(rawAssembly, rawSymbolStore, securityEvidence, ref stackMark, fIntrospection:
false,
SecurityContextSource.CurrentAssembly);
1963 [SecuritySafeCritical]
1964 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1967 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1968 return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, assemblySecurity,
null, ref stackMark, throwOnFileNotFound:
true, forIntrospection:
false, suppressSecurityChecks:
false);
1984 [SecuritySafeCritical]
1985 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
1988 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1989 return RuntimeAssembly.InternalLoad(assemblyString, assemblySecurity, ref stackMark, forIntrospection:
false);
2024 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2047 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2050 if (assemblySecurity !=
null && !IsLegacyCasPolicyEnabled)
2054 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
LoadFrom(assemblyFile, assemblySecurity);
2057 args =
new string[0];
2059 return nExecuteAssembly(assembly, args);
2079 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
LoadFrom(assemblyFile);
2082 args =
new string[0];
2084 return nExecuteAssembly(assembly, args);
2106 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2109 if (assemblySecurity !=
null && !IsLegacyCasPolicyEnabled)
2113 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
LoadFrom(assemblyFile, assemblySecurity, hashValue, hashAlgorithm);
2116 args =
new string[0];
2118 return nExecuteAssembly(assembly, args);
2140 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
LoadFrom(assemblyFile, hashValue, hashAlgorithm);
2143 args =
new string[0];
2145 return nExecuteAssembly(assembly, args);
2176 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssemblyByName which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2197 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssemblyByName which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2200 if (assemblySecurity !=
null && !IsLegacyCasPolicyEnabled)
2204 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
Load(assemblyName, assemblySecurity);
2207 args =
new string[0];
2209 return nExecuteAssembly(assembly, args);
2227 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
Load(assemblyName);
2230 args =
new string[0];
2232 return nExecuteAssembly(assembly, args);
2248 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssemblyByName which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2251 if (assemblySecurity !=
null && !IsLegacyCasPolicyEnabled)
2255 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
Load(assemblyName, assemblySecurity);
2258 args =
new string[0];
2260 return nExecuteAssembly(assembly, args);
2276 RuntimeAssembly assembly = (RuntimeAssembly)
Assembly.
Load(assemblyName);
2279 args =
new string[0];
2281 return nExecuteAssembly(assembly, args);
2286 if (_SecurityIdentity !=
null)
2288 return _SecurityIdentity.GetHostEvidence(type);
2290 return new Evidence(
new AppDomainEvidenceFactory(
this)).GetHostEvidence(type);
2296 [SecuritySafeCritical]
2300 string text = nGetFriendlyName();
2306 if (_Policies ==
null || _Policies.Length == 0)
2313 for (
int i = 0; i < _Policies.Length; i++)
2315 stringBuilder.
Append(_Policies[i]);
2319 return StringBuilderCache.GetStringAndRelease(stringBuilder);
2327 return nGetAssemblies(forIntrospection:
false);
2335 return nGetAssemblies(forIntrospection:
true);
2339 [SecuritySafeCritical]
2340 private extern Assembly[] nGetAssemblies(
bool forIntrospection);
2344 internal extern bool IsUnloadingForcedFinalize();
2350 [SecuritySafeCritical]
2355 internal static extern void PublishAnonymouslyHostedDynamicMethodsAssembly(RuntimeAssembly assemblyHandle);
2361 [Obsolete(
"AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
2364 if (path ==
null || path.Length == 0)
2368 string text = FusionStore.Value[5];
2370 if (text !=
null && text.Length > 0)
2372 stringBuilder.
Append(text);
2378 stringBuilder.
Append(path);
2379 string stringAndRelease = StringBuilderCache.GetStringAndRelease(stringBuilder);
2380 InternalSetPrivateBinPath(stringAndRelease);
2386 [Obsolete(
"AppDomain.ClearPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
2389 InternalSetPrivateBinPath(
string.Empty);
2395 [Obsolete(
"AppDomain.ClearShadowCopyPath has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyDirectories instead. http://go.microsoft.com/fwlink/?linkid=14202")]
2398 InternalSetShadowCopyPath(
string.Empty);
2405 [Obsolete(
"AppDomain.SetCachePath has been deprecated. Please investigate the use of AppDomainSetup.CachePath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
2408 InternalSetCachePath(path);
2418 SetDataHelper(name, data,
null);
2432 SetDataHelper(name, data, permission);
2436 private void SetDataHelper(
string name,
object data,
IPermission permission)
2442 if (name.Equals(
"TargetFrameworkName"))
2447 if (name.Equals(
"IgnoreSystemPolicy"))
2453 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_SetData"));
2458 int num = AppDomainSetup.Locate(name);
2463 LocalStore[name] =
new object[2]
2471 if (permission !=
null)
2473 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_SetData"));
2478 FusionStore.DynamicBase = (string)data;
2481 FusionStore.DeveloperPath = (string)data;
2484 FusionStore.ShadowCopyDirectories = (string)data;
2489 FusionStore.DisallowPublisherPolicy =
true;
2493 FusionStore.DisallowPublisherPolicy =
false;
2499 FusionStore.DisallowCodeDownload =
true;
2503 FusionStore.DisallowCodeDownload =
false;
2509 FusionStore.DisallowBindingRedirects =
true;
2513 FusionStore.DisallowBindingRedirects =
false;
2519 FusionStore.DisallowApplicationBaseProbing =
true;
2523 FusionStore.DisallowApplicationBaseProbing =
false;
2527 FusionStore.SetConfigurationBytes((
byte[])data);
2530 FusionStore.Value[num] = (string)data;
2541 [SecuritySafeCritical]
2554 return FusionStore.LoaderOptimization;
2559 LocalStore.TryGetValue(name, out value);
2565 if (value[1] !=
null)
2573 return FusionStore.ApplicationBase;
2575 return FusionStore.ApplicationName;
2577 return FusionStore.ConfigurationFile;
2579 return FusionStore.DynamicBase;
2581 return FusionStore.DeveloperPath;
2583 return FusionStore.PrivateBinPath;
2585 return FusionStore.PrivateBinPathProbe;
2587 return FusionStore.ShadowCopyDirectories;
2589 return FusionStore.ShadowCopyFiles;
2591 return FusionStore.CachePath;
2593 return FusionStore.LicenseFile;
2595 return FusionStore.DisallowPublisherPolicy;
2597 return FusionStore.DisallowCodeDownload;
2599 return FusionStore.DisallowBindingRedirects;
2601 return FusionStore.DisallowApplicationBaseProbing;
2603 return FusionStore.GetConfigurationBytes();
2614 bool? result = (!_compatFlagsInitialized) ?
null :
new bool?(_compatFlags !=
null && _compatFlags.
ContainsKey(value));
2620 [DllImport(
"kernel32.dll")]
2621 [Obsolete(
"AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink/?linkid=14202",
false)]
2631 [SecuritySafeCritical]
2632 [ReliabilityContract(
Consistency.MayCorruptAppDomain,
Cer.MayFail)]
2642 int idForUnload = GetIdForUnload(domain);
2643 if (idForUnload == 0)
2647 nUnload(idForUnload);
2662 [Obsolete(
"AppDomain policy levels are obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
2665 if (domainPolicy ==
null)
2669 if (!IsLegacyCasPolicyEnabled)
2679 _HasSetPolicy =
true;
2680 nChangeSecurityPolicy();
2691 [SecuritySafeCritical]
2695 if (principal ==
null)
2701 if (_DefaultPrincipal !=
null)
2705 _DefaultPrincipal = principal;
2712 [SecuritySafeCritical]
2716 _PrincipalPolicy = policy;
2734 if (callBackDelegate ==
null)
2766 if (shadowCopyFiles)
2770 return CreateDomain(friendlyName, securityInfo, appDomainSetup);
2775 private extern string GetDynamicDir();
2788 private static byte[] MarshalObject(
object o)
2791 return Serialize(o);
2795 private static byte[] MarshalObjects(
object o1,
object o2, out
byte[] blob2)
2798 byte[] result = Serialize(o1);
2799 blob2 = Serialize(o2);
2804 private static object UnmarshalObject(
byte[] blob)
2807 return Deserialize(blob);
2811 private static object UnmarshalObjects(
byte[] blob1,
byte[] blob2, out
object o2)
2814 object result = Deserialize(blob1);
2815 o2 = Deserialize(blob2);
2820 private static byte[] Serialize(
object o)
2832 securityElement.ToWriter(streamWriter);
2833 streamWriter.
Flush();
2834 return memoryStream.
ToArray();
2838 CrossAppDomainSerializer.SerializeObject(o, memoryStream2);
2839 return memoryStream2.
ToArray();
2843 private static object Deserialize(
byte[] blob)
2851 Parser parser =
new Parser(blob, Tokenizer.ByteTokenEncoding.UTF8Tokens, 1);
2853 if (topElement.
Tag.Equals(
"IPermission") || topElement.
Tag.Equals(
"Permission"))
2856 if (permission ==
null)
2860 permission.
FromXml(topElement);
2863 if (topElement.
Tag.Equals(
"PermissionSet"))
2866 permissionSet.
FromXml(topElement, allowInternalOnly:
false, ignoreTypeLoadFailures:
false);
2867 return permissionSet;
2869 if (topElement.
Tag.Equals(
"PermissionToken"))
2871 PermissionToken permissionToken =
new PermissionToken();
2872 permissionToken.FromXml(topElement);
2873 return permissionToken;
2880 return CrossAppDomainSerializer.DeserializeObject(stm);
2885 internal static void Pause()
2887 AppDomainPauseManager.Instance.Pausing();
2888 AppDomainPauseManager.Instance.Paused();
2892 internal static void Resume()
2894 if (AppDomainPauseManager.IsPaused)
2896 AppDomainPauseManager.Instance.Resuming();
2897 AppDomainPauseManager.Instance.Resumed();
2903 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_Constructor"));
2907 [SecuritySafeCritical]
2908 private extern int _nExecuteAssembly(RuntimeAssembly assembly,
string[] args);
2910 internal int nExecuteAssembly(RuntimeAssembly assembly,
string[] args)
2912 return _nExecuteAssembly(assembly, args);
2915 internal void CreateRemotingData()
2919 if (_RemotingData ==
null)
2921 _RemotingData =
new DomainSpecificRemotingData();
2928 private extern string nGetFriendlyName();
2932 private extern bool nIsDefaultAppDomainForEvidence();
2934 private void OnAssemblyLoadEvent(RuntimeAssembly LoadedAssembly)
2937 if (assemblyLoad !=
null)
2939 AssemblyLoadEventArgs args =
new AssemblyLoadEventArgs(LoadedAssembly);
2940 assemblyLoad(
this, args);
2945 private RuntimeAssembly OnResourceResolveEvent(RuntimeAssembly assembly,
string resourceName)
2948 if (resourceResolve ==
null)
2952 Delegate[] invocationList = resourceResolve.GetInvocationList();
2953 int num = invocationList.Length;
2954 for (
int i = 0; i < num; i++)
2957 RuntimeAssembly runtimeAssembly = GetRuntimeAssembly(
asm);
2958 if (runtimeAssembly !=
null)
2960 return runtimeAssembly;
2967 private RuntimeAssembly OnTypeResolveEvent(RuntimeAssembly assembly,
string typeName)
2970 if (typeResolve ==
null)
2974 Delegate[] invocationList = typeResolve.GetInvocationList();
2975 int num = invocationList.Length;
2976 for (
int i = 0; i < num; i++)
2979 RuntimeAssembly runtimeAssembly = GetRuntimeAssembly(
asm);
2980 if (runtimeAssembly !=
null)
2982 return runtimeAssembly;
2989 private RuntimeAssembly OnAssemblyResolveEvent(RuntimeAssembly assembly,
string assemblyFullName)
2992 if (assemblyResolve ==
null)
2996 Delegate[] invocationList = assemblyResolve.GetInvocationList();
2997 int num = invocationList.Length;
2998 for (
int i = 0; i < num; i++)
3001 RuntimeAssembly runtimeAssembly = GetRuntimeAssembly(
asm);
3002 if (runtimeAssembly !=
null)
3004 return runtimeAssembly;
3010 private RuntimeAssembly OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly,
string assemblyFullName)
3013 if (reflectionOnlyAssemblyResolve !=
null)
3015 Delegate[] invocationList = reflectionOnlyAssemblyResolve.GetInvocationList();
3016 int num = invocationList.Length;
3017 for (
int i = 0; i < num; i++)
3020 RuntimeAssembly runtimeAssembly = GetRuntimeAssembly(
asm);
3021 if (runtimeAssembly !=
null)
3023 return runtimeAssembly;
3030 private RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(RuntimeAssembly assembly,
string namespaceName)
3035 private string[] OnDesignerNamespaceResolveEvent(
string namespaceName)
3040 internal static RuntimeAssembly GetRuntimeAssembly(
Assembly asm)
3046 RuntimeAssembly runtimeAssembly =
asm as RuntimeAssembly;
3047 if (runtimeAssembly !=
null)
3049 return runtimeAssembly;
3052 if (assemblyBuilder !=
null)
3054 return assemblyBuilder.InternalAssembly;
3059 private void TurnOnBindingRedirects()
3065 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.MayFail)]
3066 internal static int GetIdForUnload(AppDomain domain)
3077 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
3078 internal static extern bool IsDomainIdValid(
int id);
3082 internal static extern AppDomain GetDefaultDomain();
3087 if (_DefaultPrincipal ==
null)
3089 switch (_PrincipalPolicy)
3104 return _DefaultPrincipal;
3108 internal void CreateDefaultContext()
3112 if (_DefaultContext ==
null)
3114 _DefaultContext =
Context.CreateDefaultContext();
3120 internal Context GetDefaultContext()
3122 if (_DefaultContext ==
null)
3124 CreateDefaultContext();
3126 return _DefaultContext;
3129 [SecuritySafeCritical]
3130 internal static void CheckDomainCreationEvidence(AppDomainSetup creationDomainSetup,
Evidence creationEvidence)
3132 if (creationEvidence !=
null && !
CurrentDomain.IsLegacyCasPolicyEnabled && (creationDomainSetup ==
null || creationDomainSetup.ApplicationTrust ==
null))
3135 Zone hostEvidence = creationEvidence.GetHostEvidence<
Zone>();
3136 if (hostEvidence !=
null && hostEvidence.SecurityZone != securityZone && hostEvidence.SecurityZone != 0)
3138 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_RequiresCasPolicyImplicit"));
3150 [SecuritySafeCritical]
3154 return InternalCreateDomain(friendlyName, securityInfo, info);
3160 if (friendlyName ==
null)
3164 CheckCreateDomainSupported();
3167 info =
new AppDomainSetup();
3169 if (info.TargetFrameworkName ==
null)
3171 info.TargetFrameworkName =
CurrentDomain.GetTargetFrameworkName();
3174 if (domainManager !=
null)
3176 return domainManager.
CreateDomain(friendlyName, securityInfo, info);
3178 if (securityInfo !=
null)
3181 CheckDomainCreationEvidence(info, securityInfo);
3183 return nCreateDomain(friendlyName, info, securityInfo, (securityInfo ==
null) ?
CurrentDomain.InternalEvidence :
null,
CurrentDomain.GetSecurityDescriptor());
3203 if (info.ApplicationBase ==
null)
3207 if (fullTrustAssemblies ==
null)
3211 info.ApplicationTrust =
new ApplicationTrust(grantSet, fullTrustAssemblies);
3234 if (shadowCopyFiles)
3238 return CreateDomain(friendlyName, securityInfo, appDomainSetup);
3244 _FusionStore = info;
3245 if (oldInfo ==
null)
3247 if (info.Value[0] ==
null || info.Value[1] ==
null)
3249 AppDomain defaultDomain = GetDefaultDomain();
3250 if (
this == defaultDomain)
3252 info.SetupDefaults(
RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized:
true);
3256 if (info.Value[1] ==
null)
3258 info.ConfigurationFile = defaultDomain.FusionStore.Value[1];
3260 if (info.Value[0] ==
null)
3262 info.ApplicationBase = defaultDomain.FusionStore.Value[0];
3264 if (info.Value[4] ==
null)
3266 info.ApplicationName = defaultDomain.FusionStore.Value[4];
3270 if (info.Value[5] ==
null)
3272 info.PrivateBinPath = Environment.nativeGetEnvironmentVariable(AppDomainSetup.PrivateBinPathEnvironmentVariable);
3274 if (info.DeveloperPath ==
null)
3279 IntPtr fusionContext = GetFusionContext();
3280 info.SetupFusionContext(fusionContext, oldInfo);
3281 if (info.LoaderOptimization != 0 || (oldInfo !=
null && info.LoaderOptimization != oldInfo.
LoaderOptimization))
3283 UpdateLoaderOptimization(info.LoaderOptimization);
3287 private static void RunInitializer(AppDomainSetup setup)
3289 if (setup.AppDomainInitializer !=
null)
3291 string[] args =
null;
3292 if (setup.AppDomainInitializerArguments !=
null)
3294 args = (
string[])setup.AppDomainInitializerArguments.Clone();
3296 setup.AppDomainInitializer(args);
3301 private static object PrepareDataForSetup(
string friendlyName, AppDomainSetup setup,
Evidence providedSecurityInfo,
Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor,
string sandboxName,
string[] propertyNames,
string[] propertyValues)
3303 byte[] array =
null;
3305 EvidenceCollection evidenceCollection =
null;
3306 if (providedSecurityInfo !=
null || creatorsSecurityInfo !=
null)
3311 if (providedSecurityInfo !=
null && providedSecurityInfo.IsUnmodified && providedSecurityInfo.Target !=
null && providedSecurityInfo.Target is AppDomainEvidenceFactory)
3313 providedSecurityInfo =
null;
3316 if (creatorsSecurityInfo !=
null && creatorsSecurityInfo.IsUnmodified && creatorsSecurityInfo.Target !=
null && creatorsSecurityInfo.Target is AppDomainEvidenceFactory)
3318 creatorsSecurityInfo =
null;
3323 if (providedSecurityInfo !=
null || creatorsSecurityInfo !=
null)
3325 evidenceCollection =
new EvidenceCollection();
3326 evidenceCollection.ProvidedSecurityInfo = providedSecurityInfo;
3327 evidenceCollection.CreatorsSecurityInfo = creatorsSecurityInfo;
3329 if (evidenceCollection !=
null)
3331 array = CrossAppDomainSerializer.SerializeObject(evidenceCollection).GetBuffer();
3333 AppDomainInitializerInfo appDomainInitializerInfo =
null;
3334 if (setup !=
null && setup.AppDomainInitializer !=
null)
3336 appDomainInitializerInfo =
new AppDomainInitializerInfo(setup.AppDomainInitializer);
3338 AppDomainSetup appDomainSetup =
new AppDomainSetup(setup, copyDomainBoundData:
false);
3339 return new object[9]
3343 parentSecurityDescriptor,
3346 appDomainInitializerInfo,
3355 private static object Setup(
object arg)
3357 object[] array = (
object[])arg;
3358 string friendlyName = (string)array[0];
3359 AppDomainSetup appDomainSetup = (AppDomainSetup)array[1];
3360 IntPtr parentSecurityDescriptor = (IntPtr)array[2];
3361 bool generateDefaultEvidence = (bool)array[3];
3362 byte[] array2 = (
byte[])array[4];
3363 AppDomainInitializerInfo appDomainInitializerInfo = (AppDomainInitializerInfo)array[5];
3364 string text = (string)array[6];
3365 string[] array3 = (
string[])array[7];
3366 string[] array4 = (
string[])array[8];
3368 Evidence creatorsSecurityInfo =
null;
3370 AppDomainSetup appDomainSetup2 =
new AppDomainSetup(appDomainSetup, copyDomainBoundData:
false);
3371 if (array3 !=
null && array4 !=
null)
3373 for (
int i = 0; i < array3.Length; i++)
3375 if (array3[i] ==
"APPBASE")
3377 if (array4[i] ==
null)
3379 throw new ArgumentNullException(
"APPBASE");
3381 if (
Path.IsRelative(array4[i]))
3383 throw new ArgumentException(Environment.GetResourceString(
"Argument_AbsolutePathRequired"));
3385 appDomainSetup2.ApplicationBase = NormalizePath(array4[i], fullCheck:
true);
3387 else if (array3[i] ==
"LOCATION_URI" && evidence ==
null)
3390 evidence.AddHostEvidence(
new Url(array4[i]));
3391 currentDomain.SetDataHelper(array3[i], array4[i],
null);
3393 else if (array3[i] ==
"LOADER_OPTIMIZATION")
3395 if (array4[i] ==
null)
3397 throw new ArgumentNullException(
"LOADER_OPTIMIZATION");
3401 case "SingleDomain":
3407 case "MultiDomainHost":
3410 case "NotSpecified":
3414 throw new ArgumentException(Environment.GetResourceString(
"Argument_UnrecognizedLoaderOptimization"),
"LOADER_OPTIMIZATION");
3419 AppDomainSortingSetupInfo appDomainSortingSetupInfo = appDomainSetup2._AppDomainSortingSetupInfo;
3420 if (appDomainSortingSetupInfo !=
null && (appDomainSortingSetupInfo._pfnIsNLSDefinedString == IntPtr.Zero || appDomainSortingSetupInfo._pfnCompareStringEx == IntPtr.Zero || appDomainSortingSetupInfo._pfnLCMapStringEx == IntPtr.Zero || appDomainSortingSetupInfo._pfnFindNLSStringEx == IntPtr.Zero || appDomainSortingSetupInfo._pfnCompareStringOrdinal == IntPtr.Zero || appDomainSortingSetupInfo._pfnGetNLSVersionEx == IntPtr.Zero) && (!(appDomainSortingSetupInfo._pfnIsNLSDefinedString == IntPtr.Zero) || !(appDomainSortingSetupInfo._pfnCompareStringEx == IntPtr.Zero) || !(appDomainSortingSetupInfo._pfnLCMapStringEx == IntPtr.Zero) || !(appDomainSortingSetupInfo._pfnFindNLSStringEx == IntPtr.Zero) || !(appDomainSortingSetupInfo._pfnCompareStringOrdinal == IntPtr.Zero) || !(appDomainSortingSetupInfo._pfnGetNLSVersionEx == IntPtr.Zero)))
3422 throw new ArgumentException(Environment.GetResourceString(
"ArgumentException_NotAllCustomSortingFuncsDefined"));
3424 currentDomain.SetupFusionStore(appDomainSetup2,
null);
3425 AppDomainSetup fusionStore = currentDomain.FusionStore;
3428 EvidenceCollection evidenceCollection = (EvidenceCollection)CrossAppDomainSerializer.DeserializeObject(
new MemoryStream(array2));
3429 evidence = evidenceCollection.ProvidedSecurityInfo;
3430 creatorsSecurityInfo = evidenceCollection.CreatorsSecurityInfo;
3432 currentDomain.nSetupFriendlyName(friendlyName);
3433 if (appDomainSetup !=
null && appDomainSetup.SandboxInterop)
3435 currentDomain.nSetDisableInterfaceCache();
3437 if (fusionStore.AppDomainManagerAssembly !=
null && fusionStore.AppDomainManagerType !=
null)
3439 currentDomain.SetAppDomainManagerType(fusionStore.AppDomainManagerAssembly, fusionStore.AppDomainManagerType);
3441 currentDomain.PartialTrustVisibleAssemblies = fusionStore.PartialTrustVisibleAssemblies;
3442 currentDomain.CreateAppDomainManager();
3443 currentDomain.InitializeDomainSecurity(evidence, creatorsSecurityInfo, generateDefaultEvidence, parentSecurityDescriptor, publishAppDomain:
true);
3444 if (appDomainInitializerInfo !=
null)
3446 fusionStore.AppDomainInitializer = appDomainInitializerInfo.Unwrap();
3448 RunInitializer(fusionStore);
3450 if (fusionStore.ActivationArguments !=
null && fusionStore.ActivationArguments.ActivateInstance)
3452 obj = Activator.CreateInstance(currentDomain.ActivationContext);
3457 [SecuritySafeCritical]
3458 internal static string NormalizePath(
string path,
bool fullCheck)
3460 return Path.LegacyNormalizePath(path, fullCheck, 260, expandShortPaths:
true);
3463 [SecuritySafeCritical]
3465 private bool IsAssemblyOnAptcaVisibleList(RuntimeAssembly assembly)
3467 if (_aptcaVisibleAssemblies ==
null)
3472 string nameWithPublicKey = name.GetNameWithPublicKey();
3473 nameWithPublicKey = nameWithPublicKey.ToUpperInvariant();
3474 int num = Array.BinarySearch(_aptcaVisibleAssemblies, nameWithPublicKey, StringComparer.OrdinalIgnoreCase);
3479 private unsafe
bool IsAssemblyOnAptcaVisibleListRaw(
char* namePtr,
int nameLen,
byte* keyTokenPtr,
int keyTokenLen)
3481 if (_aptcaVisibleAssemblies ==
null)
3485 string name =
new string(namePtr, 0, nameLen);
3486 byte[] array =
new byte[keyTokenLen];
3487 for (
int i = 0; i < array.Length; i++)
3489 array[i] = keyTokenPtr[i];
3492 assemblyName.
Name = name;
3496 int num = Array.BinarySearch(_aptcaVisibleAssemblies, assemblyName,
new CAPTCASearcher());
3499 catch (InvalidOperationException)
3506 private void SetupDomain(
bool allowRedirects,
string path,
string configFile,
string[] propertyNames,
string[] propertyValues)
3510 if (_FusionStore ==
null)
3512 AppDomainSetup appDomainSetup =
new AppDomainSetup();
3513 appDomainSetup.SetupDefaults(
RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized:
true);
3516 appDomainSetup.Value[0] = path;
3518 if (configFile !=
null)
3520 appDomainSetup.Value[1] = configFile;
3522 if (!allowRedirects)
3524 appDomainSetup.DisallowBindingRedirects =
true;
3526 if (propertyNames !=
null)
3528 for (
int i = 0; i < propertyNames.Length; i++)
3530 if (
string.
Equals(propertyNames[i],
"PARTIAL_TRUST_VISIBLE_ASSEMBLIES",
StringComparison.Ordinal) && propertyValues[i] !=
null)
3532 if (propertyValues[i].Length > 0)
3534 appDomainSetup.PartialTrustVisibleAssemblies = propertyValues[i].Split(
';');
3538 appDomainSetup.PartialTrustVisibleAssemblies =
new string[0];
3543 PartialTrustVisibleAssemblies = appDomainSetup.PartialTrustVisibleAssemblies;
3544 SetupFusionStore(appDomainSetup,
null);
3554 FusionStore.LoaderOptimization = policy;
3555 UpdateLoaderOptimization(FusionStore.LoaderOptimization);
3561 internal extern IntPtr GetFusionContext();
3565 internal extern IntPtr GetSecurityDescriptor();
3569 internal static extern AppDomain nCreateDomain(
string friendlyName, AppDomainSetup setup,
Evidence providedSecurityInfo,
Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor);
3573 internal static extern ObjRef nCreateInstance(
string friendlyName, AppDomainSetup setup,
Evidence providedSecurityInfo,
Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor);
3576 private void SetupDomainSecurity(
Evidence appDomainEvidence, IntPtr creatorsSecurityDescriptor,
bool publishAppDomain)
3579 SetupDomainSecurity(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref o), creatorsSecurityDescriptor, publishAppDomain);
3584 [SuppressUnmanagedCodeSecurity]
3585 private static extern void SetupDomainSecurity(AppDomainHandle appDomain, ObjectHandleOnStack appDomainEvidence, IntPtr creatorsSecurityDescriptor, [MarshalAs(
UnmanagedType.Bool)]
bool publishAppDomain);
3589 private extern void nSetupFriendlyName(
string friendlyName);
3592 private extern void nSetDisableInterfaceCache();
3602 [Obsolete(
"AppDomain.SetShadowCopyPath has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyDirectories instead. http://go.microsoft.com/fwlink/?linkid=14202")]
3605 InternalSetShadowCopyPath(path);
3611 [Obsolete(
"AppDomain.SetShadowCopyFiles has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyFiles instead. http://go.microsoft.com/fwlink/?linkid=14202")]
3614 InternalSetShadowCopyFiles();
3621 [Obsolete(
"AppDomain.SetDynamicBase has been deprecated. Please investigate the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")]
3624 InternalSetDynamicBase(path);
3628 internal void InternalSetShadowCopyPath(
string path)
3632 IntPtr fusionContext = GetFusionContext();
3635 FusionStore.ShadowCopyDirectories = path;
3639 internal void InternalSetShadowCopyFiles()
3641 IntPtr fusionContext = GetFusionContext();
3642 AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.ShadowCopyFilesKey,
"true");
3643 FusionStore.ShadowCopyFiles =
"true";
3647 internal void InternalSetCachePath(
string path)
3649 FusionStore.CachePath = path;
3650 if (FusionStore.Value[9] !=
null)
3652 IntPtr fusionContext = GetFusionContext();
3653 AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.CachePathKey, FusionStore.Value[9]);
3658 internal void InternalSetPrivateBinPath(
string path)
3660 IntPtr fusionContext = GetFusionContext();
3661 AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.PrivateBinPathKey, path);
3662 FusionStore.PrivateBinPath = path;
3666 internal void InternalSetDynamicBase(
string path)
3668 FusionStore.DynamicBase = path;
3669 if (FusionStore.Value[2] !=
null)
3671 IntPtr fusionContext = GetFusionContext();
3672 AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.DynamicBaseKey, FusionStore.Value[2]);
3678 internal extern string IsStringInterned(
string str);
3682 internal extern string GetOrInternString(
string str);
3686 [SuppressUnmanagedCodeSecurity]
3687 private static extern void GetGrantSet(AppDomainHandle domain, ObjectHandleOnStack retGrantSet);
3691 [SuppressUnmanagedCodeSecurity]
3693 private static extern bool GetIsLegacyCasPolicyEnabled(AppDomainHandle domain);
3695 [SecuritySafeCritical]
3698 if (_IsFastFullTrustDomain)
3702 if (evidence.GetDelayEvaluatedHostEvidence<
StrongName>() !=
null)
3707 object usedEvidence =
null;
3708 if (((IReportMatchMembershipCondition)strongNameMembershipCondition).Check(evidence, out usedEvidence))
3710 IDelayEvaluatedEvidence delayEvaluatedEvidence = usedEvidence as IDelayEvaluatedEvidence;
3711 if (usedEvidence !=
null)
3713 delayEvaluatedEvidence.MarkUsed();
3724 private extern void nChangeSecurityPolicy();
3728 [ReliabilityContract(
Consistency.MayCorruptAppDomain,
Cer.MayFail)]
3729 internal static extern void nUnload(
int domainInternal);
3799 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceAndUnwrap which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
3802 return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes)?.
Unwrap();
3831 return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes)?.
Unwrap();
3905 [Obsolete(
"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFromAndUnwrap which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
3908 return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes)?.
Unwrap();
3938 return CreateInstanceFrom(assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes)?.
Unwrap();
3942 [SecuritySafeCritical]
3943 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
3944 internal extern int GetId();
3958 private static AppDomainSetup InternalCreateDomainSetup(
string imageLocation)
3960 int num = imageLocation.LastIndexOf(
'\\');
3966 return appDomainSetup;
3969 private static AppDomain InternalCreateDomain(
string imageLocation)
3971 AppDomainSetup info = InternalCreateDomainSetup(imageLocation);
3977 private static extern void nEnableMonitoring();
3981 private static extern bool nMonitoringIsEnabled();
3985 private extern long nGetTotalProcessorTime();
3989 private extern long nGetTotalAllocatedMemorySize();
3993 private extern long nGetLastSurvivedMemorySize();
3997 private static extern long nGetLastSurvivedProcessMemorySize();
4000 private void InternalSetDomainContext(
string imageLocation)
4002 SetupFusionStore(InternalCreateDomainSetup(imageLocation),
null);
4007 [__DynamicallyInvokable]
4026 void _AppDomain.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
4028 throw new NotImplementedException();
4038 void _AppDomain.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
4040 throw new NotImplementedException();
4053 void _AppDomain.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid,
short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
4055 throw new NotImplementedException();
bool IsFinalizingForUnload()
Indicates whether this application domain is unloading, and the objects it contains are being finaliz...
Represents a character encoding.To browse the .NET Framework source code for this type,...
void ClearPrivatePath()
Resets the path that specifies the location of private assemblies to the empty string ("").
AppDomainManagerInitializationOptions
Specifies the action that a custom application domain manager takes when initializing a new domain.
override string ToString()
Obtains a string representation that includes the friendly name of the application domain and any con...
EventHandler< FirstChanceExceptionEventArgs > FirstChanceException
Occurs when an exception is thrown in managed code, before the runtime searches the call stack for an...
ObjectHandle CreateInstance(string assemblyName, string typeName)
Creates a new instance of the specified type defined in the specified assembly.
ResolveEventHandler ResourceResolve
Occurs when the resolution of a resource fails because the resource is not a valid linked or embedded...
Enables code to check the Windows group membership of a Windows user.
static string NewLine
Gets the newline string defined for this environment.
static Assembly ReflectionOnlyLoad(string assemblyString)
Loads an assembly into the reflection-only context, given its display name.
override void WriteByte(byte value)
Writes a byte to the current stream at the current position.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Encapsulates security decisions about an application. This class cannot be inherited.
The exception that is thrown when there is an attempt to dereference a null object reference.
Describes a set of security permissions applied to code. This class cannot be inherited.
FileIOPermissionAccess
Specifies the type of file access requested.
Contains static methods for retrieving custom attributes.
IList< StrongName > FullTrustAssemblies
Gets the list of full-trust assemblies for this application trust.
Gets an object's T:System.Security.Policy.Evidence.
static Assembly ReflectionOnlyLoadFrom(string assemblyFile)
Loads an assembly into the reflection-only context, given its path.
long MonitoringTotalAllocatedMemorySize
Gets the total size, in bytes, of all memory allocations that have been made by the application domai...
virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context)
Determines whether an application should be executed.
static void PrepareContractedDelegate(Delegate d)
Provides a way for applications to dynamically prepare T:System.AppDomain event delegates.
static ObjectHandle CreateComInstanceFrom(string assemblyName, string typeName)
Creates an instance of the COM object whose name is specified, using the named assembly file and the ...
int ExecuteAssemblyByName(string assemblyName, Evidence assemblySecurity)
Executes an assembly given its display name, using the specified evidence.
string TargetFrameworkName
Gets or sets a string that specifies the target version and profile of the .NET Framework for the app...
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
static ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName)
Creates an instance of the type whose name is specified, using the named assembly file and default co...
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static Assembly Load(string assemblyString)
Loads an assembly given the long form of its name.
Provides the strong name of a code assembly as evidence for policy evaluation. This class cannot be i...
Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
Loads the T:System.Reflection.Assembly with a common object file format (COFF) based image containing...
LoaderOptimization
An enumeration used with the T:System.LoaderOptimizationAttribute class to specify loader optimizatio...
SecurityZone
Defines the integer values corresponding to security zones used by security policy.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable< CustomAttributeBuilder > assemblyAttributes, SecurityContextSource securityContextSource)
Defines a dynamic assembly with the specified name, access mode, and custom attributes,...
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
int ExecuteAssembly(string assemblyFile)
Executes the assembly contained in the specified file.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, bool isSynchronized, IEnumerable< CustomAttributeBuilder > assemblyAttributes)
Defines a dynamic assembly using the specified name, access mode, storage directory,...
string BaseDirectory
Gets the base directory that the assembly resolver uses to probe for assemblies.
int ExecuteAssemblyByName(string assemblyName, params string[] args)
Executes the assembly given its display name, using the specified arguments.
object CreateInstanceAndUnwrap(string assemblyName, string typeName, object[] activationAttributes)
Creates a new instance of the specified type. Parameters specify the assembly where the type is defin...
Assembly Load(AssemblyName assemblyRef)
Loads an T:System.Reflection.Assembly given its T:System.Reflection.AssemblyName.
Provides the security zone of a code assembly as evidence for policy evaluation. This class cannot be...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies)
Creates a new application domain using the specified name, evidence, application domain setup informa...
override object InitializeLifetimeService()
Gives the T:System.AppDomain an infinite lifetime by preventing a lease from being created.
Defines the basic functionality of a principal object.
PermissionSet PermissionSet
Gets or sets the T:System.Security.PermissionSet of the policy statement.
string ShadowCopyFiles
Gets or sets a string that indicates whether shadow copying is turned on or off.
void SetThreadPrincipal(IPrincipal principal)
Sets the default principal object to be attached to threads if they attempt to bind to a principal wh...
Identifies the activation context for the current application. This class cannot be inherited.
Represents the security policy levels for the common language runtime. This class cannot be inherited...
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, Evidence evidence)
Defines a dynamic assembly using the specified name, access mode, and evidence.
Provides the functionality that allows a common language runtime host to participate in the flow,...
static long MonitoringSurvivedProcessMemorySize
Gets the total bytes that survived from the last collection for all application domains in the proces...
ObjectHandle CreateInstance(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
Creates a new instance of the specified type defined in the specified assembly. Parameters specify a ...
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
void SetDynamicBase(string path)
Establishes the specified directory path as the base directory for subdirectories where dynamically g...
virtual void InitializeNewDomain(AppDomainSetup appDomainInfo)
Initializes the new application domain.
HostSecurityManagerOptions
Specifies the security policy components to be used by the host security manager.
static WindowsIdentity GetCurrent()
Returns a T:System.Security.Principal.WindowsIdentity object that represents the current Windows user...
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir)
Defines a dynamic assembly using the specified name, access mode, and storage directory.
string FriendlyName
Gets the friendly name of this application domain.
void AppendPrivatePath(string path)
Appends the specified directory name to the private path list.
ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly file.
LoaderOptimization LoaderOptimization
Specifies the optimization policy used to load an executable.
StrongNamePublicKeyBlob PublicKey
Gets the T:System.Security.Permissions.StrongNamePublicKeyBlob of the current T:System....
Stores all relevant information required to generate a proxy in order to communicate with a remote ob...
int Id
Gets an integer that uniquely identifies the application domain within the process.
string RelativeSearchPath
Gets the path under the base directory where the assembly resolver should probe for private assemblie...
Version Version
Gets the T:System.Version of the current T:System.Security.Policy.StrongName.
static void Unload(AppDomain domain)
Unloads the specified application domain.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
Defines a dynamic assembly using the specified name, access mode, storage directory,...
ActivationContext ActivationContext
Gets the activation context for the current application domain.
int ExecuteAssemblyByName(string assemblyName, Evidence assemblySecurity, params string[] args)
Executes the assembly given its display name, using the specified evidence and arguments.
ApplicationIdentity ApplicationIdentity
Gets the identity of the application in the application domain.
SecurityContextSource
Identifies the source for the security context.
void Demand()
Throws a T:System.Security.SecurityException at run time if the security requirement is not met.
Evidence Evidence
Gets the T:System.Security.Policy.Evidence associated with this application domain.
string [] AppDomainInitializerArguments
Gets or sets the arguments passed to the callback method represented by the T:System....
Provides a collection of static methods that return information about the common language runtime env...
static bool MonitoringIsEnabled
Gets or sets a value that indicates whether CPU and memory monitoring of application domains is enabl...
Assembly Load(AssemblyName assemblyRef, Evidence assemblySecurity)
Loads an T:System.Reflection.Assembly given its T:System.Reflection.AssemblyName.
Determines whether an assembly belongs to a code group by testing its strong name....
Defines an environment for the objects that are resident inside it and for which a policy can be enfo...
Defines and represents a dynamic assembly.
static Assembly GetEntryAssembly()
Gets the process executable in the default application domain. In other application domains,...
string ConfigurationFile
Gets or sets the name of the configuration file for an application domain.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, Evidence evidence)
Defines a dynamic assembly using the specified name, access mode, storage directory,...
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access)
Defines a dynamic assembly with the specified name and access mode.
void SetCachePath(string path)
Establishes the specified directory path as the location where assemblies are shadow copied.
Assembly Load(string assemblyString)
Loads an T:System.Reflection.Assembly given its display name.
Evidence Clone()
Returns a duplicate copy of this evidence object.
int ExecuteAssemblyByName(AssemblyName assemblyName, Evidence assemblySecurity, params string[] args)
Executes the assembly given an T:System.Reflection.AssemblyName, using the specified evidence and arg...
Provides the URL from which a code assembly originates as evidence for policy evaluation....
string ApplicationBase
Gets or sets the name of the directory containing the application.
AssemblyBuilderAccess
Defines the access modes for a dynamic assembly.
string Tag
Gets or sets the tag name of an XML element.
virtual AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
Returns a new or existing application domain.
Provides a base class from which all objects to be used as evidence must derive.
void SetShadowCopyPath(string path)
Establishes the specified directory path as the location of assemblies to be shadow copied.
static Delegate Remove(Delegate source, Delegate value)
Removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
static Delegate Combine(Delegate a, Delegate b)
Concatenates the invocation lists of two delegates.
Represents a generic user.
void FromXml(SecurityElement e)
Reconstructs a security object with a specified state from an XML encoding.
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
delegate void CrossAppDomainDelegate()
Used by M:System.AppDomain.DoCallBack(System.CrossAppDomainDelegate) for cross-application domain cal...
bool IsHomogenous
Gets a value that indicates whether the current application domain has a set of permissions that is g...
Represents an application domain, which is an isolated environment where applications execute....
bool ContainsKey(TKey key)
Determines whether the T:System.Collections.Generic.Dictionary`2 contains the specified key.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
Defines a dynamic assembly using the specified name, access mode, storage directory,...
new Type GetType()
Gets the type of the current instance.
The exception that is thrown when an attempt to unload an application domain fails.
void SetShadowCopyFiles()
Turns on shadow copying.
Cer
Specifies a method's behavior when called within a constrained execution region.
Represents assembly binding information that can be added to an instance of T:System....
Represents a Windows user.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, bool isSynchronized, IEnumerable< CustomAttributeBuilder > assemblyAttributes)
Defines a dynamic assembly with the specified name, access mode, storage directory,...
Contains methods to create types of objects locally or remotely, or obtain references to existing rem...
ObjectHandle CreateComInstanceFrom(string assemblyName, string typeName)
Creates a new instance of a specified COM type. Parameters specify the name of a file that contains a...
Represents the context for the trust manager to consider when making the decision to run an applicati...
int Compare(object x, object y)
Compares two objects and returns a value indicating whether one is less than, equal to,...
void SetData(string name, object data, IPermission permission)
Assigns the specified value to the specified application domain property, with a specified permission...
SecurityAction
Specifies the security actions that can be performed using declarative security.
bool? IsCompatibilitySwitchSet(string value)
Gets a nullable Boolean value that indicates whether any compatibility switches are set,...
Implements a T:System.IO.TextWriter for writing characters to a stream in a particular encoding....
Provides information about, and means to manipulate, the current environment and platform....
ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
Creates a new instance of the specified type defined in the specified assembly file.
EventHandler DomainUnload
Occurs when an T:System.AppDomain is about to be unloaded.
Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type...
object CreateInstanceFromAndUnwrap(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly file,...
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
bool IsDefaultAppDomain()
Returns a value that indicates whether the application domain is the default application domain for t...
string Name
Gets or sets the simple name of the assembly. This is usually, but not necessarily,...
virtual PolicyLevel DomainPolicy
When overridden in a derived class, gets the security policy for the current application domain.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, string dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, bool isSynchronized)
Defines a dynamic assembly using the specified name, access mode, storage directory,...
Represents a collection that can contain many different types of permissions.
virtual byte [] ToArray()
Writes the stream contents to a byte array, regardless of the P:System.IO.MemoryStream....
static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup info)
Creates a new application domain using the specified name, evidence, and application domain setup inf...
string ApplyPolicy(string assemblyName)
Returns the assembly display name after policy has been applied.
UnmanagedType
Identifies how to marshal parameters or fields to unmanaged code.
long MonitoringSurvivedMemorySize
Gets the number of bytes that survived the last collection and that are known to be referenced by the...
virtual Evidence ProvideAppDomainEvidence(Evidence inputEvidence)
Provides the application domain evidence for an assembly being loaded.
void ClearShadowCopyPath()
Resets the list of directories containing shadow copied assemblies to the empty string ("").
Represents the XML object model for encoding security objects. This class cannot be inherited.
ResolveEventHandler TypeResolve
Occurs when the resolution of a type fails.
delegate void EventHandler(object sender, EventArgs e)
Represents the method that will handle an event that has no event data.
void SetAppDomainPolicy(PolicyLevel domainPolicy)
Establishes the security policy level for this application domain.
virtual HostSecurityManager HostSecurityManager
Gets the host security manager that participates in security decisions for the application domain.
Defines the methods that convert permission object state to and from XML element representation.
virtual void FromXml(SecurityElement et)
Reconstructs a security object with a specified state from an XML encoding.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable< CustomAttributeBuilder > assemblyAttributes)
Defines a dynamic assembly with the specified name, access mode, and custom attributes.
AppDomainSetup SetupInformation
Gets the application domain configuration information for this instance.
PrincipalPolicy
Specifies how principal and identity objects should be created for an application domain....
new bool Equals(object other)
Provides COM objects with version-independent access to the inherited M:System.Object....
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
delegate void AssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args)
Represents the method that handles the E:System.AppDomain.AssemblyLoad event of an T:System....
ObjectHandle CreateInstance(string assemblyName, string typeName, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly. A parameter specifies...
Defines the underlying structure of all code access permissions.
A platform-specific type that is used to represent a pointer or a handle.
Assembly Load(string assemblyString, Evidence assemblySecurity)
Loads an T:System.Reflection.Assembly given its display name.
TimeSpan MonitoringTotalProcessorTime
Gets the total processor time that has been used by all threads while executing in the current applic...
Exposes a method that compares two objects.
object CreateInstanceAndUnwrap(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
Creates a new instance of the specified type. Parameters specify the name of the type,...
string DynamicDirectory
Gets the directory that the assembly resolver uses to probe for dynamically created assemblies.
AssemblyLoadEventHandler AssemblyLoad
Occurs when an assembly is loaded.
Ability to provide evidence, including the ability to alter the evidence provided by the common langu...
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Represents type declarations: class types, interface types, array types, value types,...
void Add(T item)
Adds an object to the end of the T:System.Collections.ObjectModel.Collection`1.
int ExecuteAssembly(string assemblyFile, Evidence assemblySecurity)
Executes the assembly contained in the specified file, using the specified evidence.
void SetPrincipalPolicy(PrincipalPolicy policy)
Specifies how principal and identity objects should be attached to a thread if the thread attempts to...
bool DisallowBindingRedirects
Gets or sets a value that indicates whether an application domain allows assembly binding redirection...
Assembly [] GetAssemblies()
Gets the assemblies that have been loaded into the execution context of this application domain.
bool??? IsFullyTrusted
Gets a value that indicates whether assemblies that are loaded into the current application domain ex...
Wraps marshal-by-value object references, allowing them to be returned through an indirection.
AppDomainManagerInitializationOptions InitializationFlags
Gets the initialization flags for custom application domain managers.
MethodImplOptions
Defines the details of how a method is implemented.
static AppDomain GetDomain()
Returns the current domain in which the current thread is running.
ApplicationTrust ApplicationTrust
Gets information describing permissions granted to an application and whether the application has a t...
CharSet
Dictates which character set marshaled strings should use.
ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly file.
ObjectHandle CreateComInstanceFrom(string assemblyFile, string typeName, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
Creates a new instance of a specified COM type. Parameters specify the name of a file that contains a...
Exposes the public members of the T:System.AppDomain class to unmanaged code.
string PrivateBinPath
Gets or sets the list of directories under the application base directory that are probed for private...
ApplicationTrust ApplicationTrust
Gets or sets an object containing security and trust information.
bool IsApplicationTrustedToRun
Gets or sets a value indicating whether the application has the required permission grants and is tru...
static readonly char PathSeparator
A platform-specific separator character used to separate path strings in environment variables.
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
static Assembly LoadFrom(string assemblyFile)
Loads an assembly given its file name or path.
Defines methods implemented by permission types.
Provides data for manifest-based activation of an application. This class cannot be inherited.
delegate void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
Represents the method that will handle the event raised by an exception that is not handled by the ap...
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
AppDomainInitializer AppDomainInitializer
Gets or sets the T:System.AppDomainInitializer delegate, which represents a callback method that is i...
static void RevertAssert()
Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed...
static bool IsTransparentProxy(object proxy)
Returns a Boolean value that indicates whether the given object is a transparent proxy or a real obje...
Provides a managed equivalent of an unmanaged host.
int ExecuteAssembly(string assemblyFile, Evidence assemblySecurity, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
Executes the assembly contained in the specified file, using the specified evidence,...
byte [] GetPublicKey()
Gets the public key of the assembly.
int ExecuteAssemblyByName(string assemblyName)
Executes an assembly given its display name.
Describes an assembly's unique identity in full.
Collection< Assembly > ResolvedAssemblies
Gets a collection of assemblies; when the event handler for the E:System.Runtime.InteropServices....
bool ShadowCopyFiles
Gets an indication whether the application domain is configured to shadow copy files.
The exception that is thrown when one of the arguments provided to a method is not valid.
static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture)
Creates an instance of the specified type using the constructor that best matches the specified param...
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
ApplicationTrust(ApplicationIdentity applicationIdentity)
Initializes a new instance of the T:System.Security.Policy.ApplicationTrust class with an T:System....
The exception that is thrown when an attempt to access a file that does not exist on disk fails.
UnhandledExceptionEventHandler UnhandledException
Occurs when an exception is not caught.
static AppDomain CreateDomain(string friendlyName)
Creates a new application domain with the specified name.
int ExecuteAssembly(string assemblyFile, Evidence assemblySecurity, string[] args)
Executes the assembly contained in the specified file, using the specified evidence and arguments.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
object CreateInstanceAndUnwrap(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly, specifying whether th...
Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore)
Loads the T:System.Reflection.Assembly with a common object file format (COFF) based image containing...
Identifies the version of the .NET Framework that a particular assembly was compiled against.
Defines the set of information that constitutes input to security policy decisions....
static AppDomain CreateDomain(string friendlyName, Evidence securityInfo)
Creates a new application domain with the given name using the supplied evidence.
PermissionSet PermissionSet
Gets the permission set of a sandboxed application domain.
Represents a time interval.To browse the .NET Framework source code for this type,...
AppDomainManager DomainManager
Gets the domain manager that was provided by the host when the application domain was initialized.
virtual HostSecurityManagerOptions Flags
Gets the flag representing the security policy components of concern to the host.
Provides the ability to uniquely identify a manifest-activated application. This class cannot be inhe...
ResolveEventHandler ReflectionOnlyAssemblyResolve
Occurs when the resolution of an assembly fails in the reflection-only context.
Specifies that the class can be serialized.
delegate void AppDomainInitializer(string[] args)
Represents the callback method to invoke when the application domain is initialized.
object CreateInstanceAndUnwrap(string assemblyName, string typeName)
Creates a new instance of the specified type. Parameters specify the assembly where the type is defin...
void SetData(string name, object data)
Assigns the specified value to the specified application domain property.
static Encoding UTF8
Gets an encoding for the UTF-8 format.
static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles)
Creates a new application domain with the given name, using evidence, application base path,...
The exception that is thrown when a method call is invalid for the object's current state.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
Defines a dynamic assembly using the specified name, access mode, evidence, and permission requests.
static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Gets the T:System.Type with the specified name, specifying whether to throw an exception if the type ...
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
object GetData(string name)
Gets the value stored in the current application domain for the specified name.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
Consistency
Specifies a reliability contract.
int ExecuteAssemblyByName(AssemblyName assemblyName, params string[] args)
Executes the assembly given an T:System.Reflection.AssemblyName, using the specified arguments.
ObjectHandle CreateInstance(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly. Parameters specify a ...
Provides the main access point for classes interacting with the security system. This class cannot be...
virtual PermissionSet Copy()
Creates a copy of the T:System.Security.PermissionSet.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
object Unwrap()
Returns the wrapped object.
object CreateInstanceFromAndUnwrap(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
Creates a new instance of the specified type defined in the specified assembly file.
Provides information about a specific culture (called a locale for unmanaged code development)....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Controls the ability to access files and folders. This class cannot be inherited.
AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
Defines a dynamic assembly using the specified name, access mode, and permission requests.
string NamespaceName
Gets the name of the namespace to resolve.
EventHandler ProcessExit
Occurs when the default application domain's parent process exits.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
SecurityPermissionFlag
Specifies access flags for the security permission object.
static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs)
Creates a new application domain with the given name, using evidence, application base path,...
void DoCallBack(CrossAppDomainDelegate callBackDelegate)
Executes the code in another application domain that is identified by the specified delegate.
Provides several methods for using and publishing remoted objects and proxies. This class cannot be i...
object CreateInstanceFromAndUnwrap(string assemblyName, string typeName, object[] activationAttributes)
Creates a new instance of the specified type defined in the specified assembly file.
Represents a generic principal.
override void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
Assembly [] ReflectionOnlyGetAssemblies()
Returns the assemblies that have been loaded into the reflection-only context of the application doma...
static int GetCurrentThreadId()
Gets the current thread identifier.
delegate Assembly ResolveEventHandler(object sender, ResolveEventArgs args)
Represents a method that handles the E:System.AppDomain.TypeResolve, E:System.AppDomain....
ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName)
Creates a new instance of the specified type defined in the specified assembly file.
The exception that is thrown when policy forbids code to run.
The exception that is thrown when a requested method or operation is not implemented.
The exception that is thrown when a security error is detected.
Performs operations on T:System.String instances that contain file or directory path information....
byte [] GetPublicKeyToken()
Gets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which ...
static IEnumerable< Attribute > GetCustomAttributes(this Assembly element)
Retrieves a collection of custom attributes that are applied to a specified assembly.
Assembly Load(byte[] rawAssembly)
Loads the T:System.Reflection.Assembly with a common object file format (COFF) based image containing...
string Name
Gets the simple name of the current T:System.Security.Policy.StrongName.
AssemblyHashAlgorithm
Specifies all the hash algorithms used for hashing files and for generating the strong name.
object CreateInstanceFromAndUnwrap(string assemblyName, string typeName)
Creates a new instance of the specified type defined in the specified assembly file.
Attribute can be applied to a delegate.
int ExecuteAssembly(string assemblyFile, string[] args)
Executes the assembly contained in the specified file, using the specified arguments.
Allows the control and customization of security behavior for application domains.
void SetPublicKeyToken(byte[] publicKeyToken)
Sets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which ...
int ExecuteAssembly(string assemblyFile, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
Executes the assembly contained in the specified file, using the specified arguments,...
Provides a set of static methods and properties that provide support for compilers....
ResolveEventHandler AssemblyResolve
Occurs when the resolution of an assembly fails.
Provides data for the E:System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMetadata....
Enables access to objects across application domain boundaries in applications that support remoting.
Creates and controls a thread, sets its priority, and gets its status.
PolicyStatement DefaultGrantSet
Gets or sets the policy statement defining the default grant set.