#endif
using System.Threading;
using System.Runtime.CompilerServices;
+using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
- public sealed class AppDomain : MarshalByRefObject {
+ public sealed partial class AppDomain : MarshalByRefObject {
#else
- public sealed class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
+ public sealed partial class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
#endif
#pragma warning disable 169
#region Sync with object-internals.h
get { return (PermissionSet)_granted; }
}
-#if NET_4_0
public PermissionSet PermissionSet {
get { return (PermissionSet)_granted ?? (PermissionSet)(_granted = new PermissionSet (PermissionState.Unrestricted)); }
}
-#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern AppDomain getCurDomain ();
}
#endif
+ internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName, string typeName)
+ {
+ return CreateInstance(assemblyName, typeName);
+ }
+
+ internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName,
+ string typeName,
+ bool ignoreCase,
+ BindingFlags bindingAttr,
+ Binder binder,
+ Object[] args,
+ CultureInfo culture,
+ Object[] activationAttributes,
+ Evidence securityAttributes)
+ {
+#pragma warning disable 618
+ return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
+#pragma warning restore 618
+ }
+
+ internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName, string typeName)
+ {
+ return CreateInstanceFrom(assemblyName, typeName);
+ }
+
+ internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName,
+ string typeName,
+ bool ignoreCase,
+ BindingFlags bindingAttr,
+ Binder binder,
+ Object[] args,
+ CultureInfo culture,
+ Object[] activationAttributes,
+ Evidence securityAttributes)
+ {
+#pragma warning disable 618
+ return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
+#pragma warning restore 618
+ }
+
public ObjectHandle CreateInstance (string assemblyName, string typeName)
{
if (assemblyName == null)
return Activator.CreateInstance (assemblyName, typeName, activationAttributes);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
Binder binder, object[] args, CultureInfo culture, object[] activationAttributes,
Evidence securityAttributes)
return (oh != null) ? oh.Unwrap () : null;
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public object CreateInstanceAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
object[] activationAttributes, Evidence securityAttributes)
return (oh != null) ? oh.Unwrap () : null;
}
-#if NET_4_0
public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
{
return (oh != null) ? oh.Unwrap () : null;
}
-#endif
public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
{
return Activator.CreateInstanceFrom (assemblyFile, typeName, activationAttributes);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
object[] activationAttributes, Evidence securityAttributes)
return (oh != null) ? oh.Unwrap () : null;
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args,
CultureInfo culture, object[] activationAttributes,
return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence)
{
return DefineDynamicAssembly (name, access, null, evidence, null, null, null, false);
return DefineDynamicAssembly (name, access, dir, null, null, null, null, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence)
{
return DefineDynamicAssembly (name, access, dir, evidence, null, null, null, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
refusedPermissions, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
refusedPermissions, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
refusedPermissions, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
refusedPermissions, false);
}
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
}
// NET 3.5 method
-#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
-#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
return DefineDynamicAssembly (name, access, null, null, null, null, null, false, assemblyAttributes);
}
-#if NET_4_0
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
{
return DefineDynamicAssembly (name, access, dir, null, null, null, null, isSynchronized, assemblyAttributes);
{
return DefineDynamicAssembly (name, access, assemblyAttributes);
}
-#endif
internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
{
return ExecuteAssembly (assemblyFile, (Evidence)null, null);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity)
{
return ExecuteAssembly (assemblyFile, assemblySecurity, null);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args)
{
Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity);
return ExecuteAssemblyInternal (a, args);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
{
Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity, hashValue, hashAlgorithm);
}
-#if NET_4_0
public int ExecuteAssembly (string assemblyFile, string[] args)
{
Assembly a = Assembly.LoadFrom (assemblyFile, null);
Assembly a = Assembly.LoadFrom (assemblyFile, null, hashValue, hashAlgorithm);
return ExecuteAssemblyInternal (a, args);
}
-#endif
int ExecuteAssemblyInternal (Assembly a, string[] args)
{
return result;
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
{
if (assemblyRef == null)
return Load (assemblyString, null, false);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public Assembly Load (string assemblyString, Evidence assemblySecurity)
{
return Load (assemblyString, assemblySecurity, false);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Assembly LoadAssemblyRaw (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence, bool refonly);
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
{
return Load (rawAssembly, rawSymbolStore, securityEvidence, false);
assembly.FromByteArray = true;
return assembly;
}
-#if NET_4_0
[Obsolete ("AppDomain policy levels are obsolete")]
-#endif
[SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
public void SetAppDomainPolicy (PolicyLevel domainPolicy)
{
return _process_guid;
}
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
public static AppDomain CreateDomain (string friendlyName)
{
return CreateDomain (friendlyName, null, null);
return ad;
}
+#else
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
#if !NET_2_1
[Serializable]
}
#endif
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath,
string appRelativeSearchPath, bool shadowCopyFiles)
{
return CreateDomain (friendlyName, securityInfo, CreateDomainSetup (appBasePath, appRelativeSearchPath, shadowCopyFiles));
}
+#else
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath,
+ string appRelativeSearchPath, bool shadowCopyFiles)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
#if !NET_2_1
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info,
PermissionSet grantSet, params StrongName [] fullTrustAssemblies)
{
info.ApplicationTrust = new ApplicationTrust (grantSet, fullTrustAssemblies ?? EmptyArray<StrongName>.Value);
return CreateDomain (friendlyName, securityInfo, info);
}
+#else
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info,
+ PermissionSet grantSet, params StrongName [] fullTrustAssemblies)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
#endif
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
static AppDomainSetup CreateDomainSetup (string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles)
{
AppDomainSetup info = new AppDomainSetup ();
return info;
}
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern bool InternalIsFinalizingForUnload (int domain_id);
return Thread.GetDomainID ();
}
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
[SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
[ReliabilityContractAttribute (Consistency.MayCorruptAppDomain, Cer.MayFail)]
public static void Unload (AppDomain domain)
InternalUnload (domain.getDomainID());
}
+#else
+ [Obsolete ("AppDomain.Unload is not supported on the current platform.", true)]
+ public static void Unload (AppDomain domain)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.Unload is not supported on the current platform.");
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
[MethodImplAttribute (MethodImplOptions.InternalCall)]
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
AssemblyLoad (this, new AssemblyLoadEventArgs (assembly));
}
- private Assembly DoAssemblyResolve (string name, bool refonly)
+ private Assembly DoAssemblyResolve (string name, Assembly requestingAssembly, bool refonly)
{
ResolveEventHandler del;
#if !NET_2_1
foreach (Delegate eh in invocation_list) {
ResolveEventHandler handler = (ResolveEventHandler) eh;
- Assembly assembly = handler (this, new ResolveEventArgs (name));
+ Assembly assembly = handler (this, new ResolveEventArgs (name, requestingAssembly));
if (assembly != null)
return assembly;
}
foreach (Delegate eh in invocation_list) {
ResolveEventHandler handler = (ResolveEventHandler) eh;
-#if NET_4_0
Assembly assembly = handler (this, new ResolveEventArgs (name, requesting));
-#else
- Assembly assembly = handler (this, new ResolveEventArgs (name));
-#endif
if (assembly != null)
return assembly;
}
return null;
}
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
private void DoDomainUnload ()
{
if (DomainUnload != null)
DomainUnload(this, null);
}
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern void DoUnhandledException (Exception e);
+
+ internal void DoUnhandledException (UnhandledExceptionEventArgs args) {
+ if (UnhandledException != null)
+ UnhandledException (this, args);
+ }
internal byte[] GetMarshalledDomainObjRef ()
{
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
public event ResolveEventHandler AssemblyResolve;
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
+#else
+ [Obsolete ("AppDomain.DomainUnload is not supported on the current platform.", true)]
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
public event EventHandler DomainUnload;
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
public event UnhandledExceptionEventHandler UnhandledException;
-#if NET_4_0
+ public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException;
+
[MonoTODO]
public bool IsHomogenous {
get { return true; }
public bool IsFullyTrusted {
get { return true; }
}
-#endif
#pragma warning disable 649
#if !MOBILE
#endif
#pragma warning restore 649
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
// default is null
public AppDomainManager DomainManager {
get { return (AppDomainManager)_domain_manager; }
}
+#else
+ [Obsolete ("AppDomain.DomainManager is not supported on this platform.", true)]
+ public AppDomainManager DomainManager {
+ get { throw new PlatformNotSupportedException ("AppDomain.DomainManager is not supported on this platform."); }
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
#if !MOBILE
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
// static methods
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath,
string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs)
{
return CreateDomain (friendlyName, securityInfo, info);
}
+#else
+ [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)]
+ public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath,
+ string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs)
+ {
+ throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform.");
+ }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
public int ExecuteAssemblyByName (string assemblyName)
{
return ExecuteAssemblyByName (assemblyName, (Evidence)null, null);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity)
{
return ExecuteAssemblyByName (assemblyName, assemblySecurity, null);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, assemblySecurity);
return ExecuteAssemblyInternal (a, args);
}
-#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
-#endif
public int ExecuteAssemblyByName (AssemblyName assemblyName, Evidence assemblySecurity, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, assemblySecurity);
return ExecuteAssemblyInternal (a, args);
}
-#if NET_4_0
public int ExecuteAssemblyByName (string assemblyName, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, null);
return ExecuteAssemblyInternal (a, args);
}
-#endif
public bool IsDefaultAppDomain ()
{
}
#endif
-#if NET_4_0
List<string> compatibility_switch;
public bool? IsCompatibilitySwitchSet (string value)
public TimeSpan MonitoringTotalProcessorTime {
get { throw new NotImplementedException (); }
}
-#endif
}
}