Merge pull request #2274 from esdrubal/udpclientreceive
[mono.git] / mcs / class / corlib / System / AppDomain.cs
index 2293f444e4d4b0c4e6af8ea4a957e7c8f6df917c..13cc078e575b0b757017347382bd9d393214a78d 100644 (file)
@@ -66,9 +66,9 @@ namespace System {
        [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
@@ -246,11 +246,9 @@ namespace System {
                        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 ();
@@ -326,6 +324,46 @@ namespace System {
                }
 #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)
@@ -342,9 +380,7 @@ namespace System {
                        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)
@@ -368,9 +404,7 @@ namespace System {
                        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)
@@ -380,7 +414,6 @@ namespace System {
                        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)
                {
@@ -419,7 +452,6 @@ namespace System {
 
                        return (oh != null) ? oh.Unwrap () : null;
                }
-#endif
 
                public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
                {
@@ -437,9 +469,7 @@ namespace System {
                        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)
@@ -463,9 +493,7 @@ namespace System {
                        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,
@@ -483,9 +511,7 @@ namespace System {
                        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);
@@ -496,18 +522,14 @@ namespace System {
                        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,
@@ -517,9 +539,7 @@ namespace System {
                                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,
@@ -529,9 +549,7 @@ namespace System {
                                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,
@@ -541,9 +559,7 @@ namespace System {
                                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,
@@ -554,9 +570,7 @@ namespace System {
                                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,
@@ -575,9 +589,7 @@ namespace System {
                }
 
                // 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,
@@ -598,7 +610,6 @@ namespace System {
                        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);
@@ -609,7 +620,6 @@ namespace System {
                {
                        return DefineDynamicAssembly (name, access, assemblyAttributes);
                }
-#endif
 
                internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
                {
@@ -632,26 +642,20 @@ namespace System {
                        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);
@@ -659,7 +663,6 @@ namespace System {
                }
 
 
-#if NET_4_0
                public int ExecuteAssembly (string assemblyFile, string[] args)
                {
                        Assembly a = Assembly.LoadFrom (assemblyFile, null);
@@ -671,7 +674,6 @@ namespace System {
                        Assembly a = Assembly.LoadFrom (assemblyFile, null, hashValue, hashAlgorithm);
                        return ExecuteAssemblyInternal (a, args);
                }
-#endif
 
                int ExecuteAssemblyInternal (Assembly a, string[] args)
                {
@@ -723,9 +725,7 @@ namespace System {
                        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)
@@ -782,9 +782,7 @@ namespace System {
                        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);
@@ -817,9 +815,7 @@ namespace System {
                [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);
@@ -834,9 +830,7 @@ namespace System {
                        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)
                {
@@ -989,6 +983,7 @@ namespace System {
                        return _process_guid;
                }
 
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
                public static AppDomain CreateDomain (string friendlyName)
                {
                        return CreateDomain (friendlyName, null, null);
@@ -1067,6 +1062,25 @@ namespace System {
 
                        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]
@@ -1104,13 +1118,23 @@ namespace System {
                }
 #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)
                {
@@ -1120,8 +1144,17 @@ namespace System {
                        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 ();
@@ -1136,6 +1169,7 @@ namespace System {
 
                        return info;
                }
+#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
                
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private static extern bool InternalIsFinalizingForUnload (int domain_id);
@@ -1155,6 +1189,7 @@ namespace System {
                        return Thread.GetDomainID ();
                }
 
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
                [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
                [ReliabilityContractAttribute (Consistency.MayCorruptAppDomain, Cer.MayFail)]
                public static void Unload (AppDomain domain)
@@ -1164,6 +1199,13 @@ namespace System {
 
                        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)]
@@ -1241,7 +1283,7 @@ namespace System {
                        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
@@ -1280,7 +1322,7 @@ namespace System {
 
                                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;
                                }
@@ -1338,22 +1380,23 @@ namespace System {
 
                        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)
@@ -1396,7 +1439,11 @@ namespace System {
                [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)]
@@ -1411,11 +1458,8 @@ namespace System {
                [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
                public event UnhandledExceptionEventHandler UnhandledException;
 
-#if NET_4_5
                public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException;
-#endif
 
-#if NET_4_0
                [MonoTODO]
                public bool IsHomogenous {
                        get { return true; }
@@ -1425,7 +1469,6 @@ namespace System {
                public bool IsFullyTrusted {
                        get { return true; }
                }
-#endif
 
         #pragma warning disable 649
 #if !MOBILE
@@ -1435,10 +1478,17 @@ namespace System {
 #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;
@@ -1484,6 +1534,7 @@ namespace System {
 
                // 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)
                {
@@ -1494,23 +1545,27 @@ namespace System {
 
                        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);
@@ -1518,9 +1573,7 @@ namespace System {
                        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);
@@ -1528,7 +1581,6 @@ namespace System {
                        return ExecuteAssemblyInternal (a, args);
                }
 
-#if NET_4_0
                public int ExecuteAssemblyByName (string assemblyName, params string[] args)
                {
                        Assembly a = Assembly.Load (assemblyName, null);
@@ -1542,7 +1594,6 @@ namespace System {
 
                        return ExecuteAssemblyInternal (a, args);
                }
-#endif
 
                public bool IsDefaultAppDomain ()
                {
@@ -1577,7 +1628,6 @@ namespace System {
                }
 #endif
 
-#if NET_4_0
                List<string> compatibility_switch;
 
                public bool? IsCompatibilitySwitchSet (string value)
@@ -1621,6 +1671,5 @@ namespace System {
                public TimeSpan MonitoringTotalProcessorTime {
                        get { throw new NotImplementedException (); }
                }
-#endif
        }
 }