5 // Paolo Molaro (lupus@ximian.com)
6 // Dietmar Maurer (dietmar@ximian.com)
7 // Miguel de Icaza (miguel@ximian.com)
8 // Gonzalo Paniagua (gonzalo@ximian.com)
10 // Sebastien Pouliot (sebastien@ximian.com)
12 // (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
13 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
14 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Globalization;
38 using System.Reflection;
40 using System.Reflection.Emit;
42 using System.Threading;
43 using System.Runtime.CompilerServices;
44 using System.Runtime.ExceptionServices;
45 using System.Runtime.InteropServices;
46 using System.Runtime.Remoting;
47 using System.Runtime.Remoting.Contexts;
48 using System.Runtime.Remoting.Channels;
49 using System.Runtime.Remoting.Messaging;
50 using System.Security;
51 using System.Security.Permissions;
52 using System.Security.Policy;
53 using System.Security.Principal;
54 using System.Configuration.Assemblies;
56 using System.Collections.Generic;
57 using System.Runtime.ConstrainedExecution;
64 [ComDefaultInterface (typeof (_AppDomain))]
66 [ClassInterface(ClassInterfaceType.None)]
67 [StructLayout (LayoutKind.Sequential)]
69 public sealed partial class AppDomain : MarshalByRefObject {
71 public sealed partial class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
73 #pragma warning disable 169
74 #region Sync with object-internals.h
75 IntPtr _mono_app_domain;
77 #pragma warning restore 169
78 static string _process_guid;
81 static Dictionary<string, object> type_resolve_in_progress;
84 static Dictionary<string, object> assembly_resolve_in_progress;
87 static Dictionary<string, object> assembly_resolve_in_progress_refonly;
90 private Evidence _evidence;
91 private PermissionSet _granted;
94 private PrincipalPolicy _principalPolicy;
97 private static IPrincipal _principal;
103 int _principalPolicy;
106 static object _principal;
110 static AppDomain default_domain;
116 [MethodImplAttribute (MethodImplOptions.InternalCall)]
117 private extern AppDomainSetup getSetup ();
122 AppDomainSetup SetupInformationNoCopy {
123 get { return getSetup (); }
126 public AppDomainSetup SetupInformation {
128 AppDomainSetup setup = getSetup ();
129 return new AppDomainSetup (setup);
135 public ApplicationTrust ApplicationTrust {
136 get { throw new NotImplementedException (); }
139 public string BaseDirectory {
141 string path = SetupInformationNoCopy.ApplicationBase;
143 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
144 // we cannot divulge local file informations
145 new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
152 public string RelativeSearchPath {
154 string path = SetupInformationNoCopy.PrivateBinPath;
156 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
157 // we cannot divulge local file informations
158 new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
165 public string DynamicDirectory {
167 AppDomainSetup setup = SetupInformationNoCopy;
168 if (setup.DynamicBase == null)
171 string path = Path.Combine (setup.DynamicBase, setup.ApplicationName);
173 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
174 // we cannot divulge local file informations
175 new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
182 public bool ShadowCopyFiles {
184 return (SetupInformationNoCopy.ShadowCopyFiles == "true");
188 [MethodImplAttribute (MethodImplOptions.InternalCall)]
189 private extern string getFriendlyName ();
191 public string FriendlyName {
193 return getFriendlyName ();
197 public Evidence Evidence {
202 // if the host (runtime) hasn't provided it's own evidence...
203 if (_evidence == null) {
204 // ... we will provide our own
206 // the executed assembly from the "default" appdomain
207 // or null if we're not in the default appdomain or
208 // if there is no entry assembly (embedded mono)
209 Assembly a = Assembly.GetEntryAssembly ();
211 if (this == DefaultDomain)
213 return new Evidence ();
215 _evidence = AppDomain.DefaultDomain.Evidence;
217 _evidence = Evidence.GetDefaultHostEvidence (a);
221 return new Evidence ((Evidence)_evidence); // return a copy
226 internal IPrincipal DefaultPrincipal {
228 if (_principal == null) {
229 switch ((PrincipalPolicy)_principalPolicy) {
230 case PrincipalPolicy.UnauthenticatedPrincipal:
231 _principal = new GenericPrincipal (
232 new GenericIdentity (String.Empty, String.Empty), null);
234 case PrincipalPolicy.WindowsPrincipal:
235 _principal = new WindowsPrincipal (WindowsIdentity.GetCurrent ());
239 return (IPrincipal)_principal;
243 // for AppDomain there is only an allowed (i.e. granted) set
244 // http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondetermininggrantedpermissions.asp
245 internal PermissionSet GrantedPermissionSet {
246 get { return (PermissionSet)_granted; }
249 public PermissionSet PermissionSet {
250 get { return (PermissionSet)_granted ?? (PermissionSet)(_granted = new PermissionSet (PermissionState.Unrestricted)); }
253 [MethodImplAttribute (MethodImplOptions.InternalCall)]
254 private static extern AppDomain getCurDomain ();
256 public static AppDomain CurrentDomain {
258 return getCurDomain ();
262 [MethodImplAttribute (MethodImplOptions.InternalCall)]
263 private static extern AppDomain getRootDomain ();
265 internal static AppDomain DefaultDomain {
267 if (default_domain == null) {
268 AppDomain rd = getRootDomain ();
269 if (rd == CurrentDomain)
272 default_domain = (AppDomain) RemotingServices.GetDomainProxy (rd);
274 return default_domain;
278 [Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
279 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
280 public void AppendPrivatePath (string path)
282 if (path == null || path.Length == 0)
285 AppDomainSetup setup = SetupInformationNoCopy;
287 string pp = setup.PrivateBinPath;
288 if (pp == null || pp.Length == 0) {
289 setup.PrivateBinPath = path;
294 if (pp [pp.Length - 1] != Path.PathSeparator)
295 pp += Path.PathSeparator;
297 setup.PrivateBinPath = pp + path;
300 [Obsolete ("AppDomain.ClearPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
301 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
302 public void ClearPrivatePath ()
304 SetupInformationNoCopy.PrivateBinPath = String.Empty;
307 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
308 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
309 public void ClearShadowCopyPath ()
311 SetupInformationNoCopy.ShadowCopyDirectories = String.Empty;
315 public ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
317 return Activator.CreateComInstanceFrom (assemblyName, typeName);
320 public ObjectHandle CreateComInstanceFrom (string assemblyFile, string typeName,
321 byte [] hashValue, AssemblyHashAlgorithm hashAlgorithm)
323 return Activator.CreateComInstanceFrom (assemblyFile, typeName, hashValue ,hashAlgorithm);
327 internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName, string typeName)
329 return CreateInstance(assemblyName, typeName);
332 internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName,
335 BindingFlags bindingAttr,
339 Object[] activationAttributes,
340 Evidence securityAttributes)
342 #pragma warning disable 618
343 return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
344 #pragma warning restore 618
347 internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName, string typeName)
349 return CreateInstanceFrom(assemblyName, typeName);
352 internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName,
355 BindingFlags bindingAttr,
359 Object[] activationAttributes,
360 Evidence securityAttributes)
362 #pragma warning disable 618
363 return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
364 #pragma warning restore 618
367 public ObjectHandle CreateInstance (string assemblyName, string typeName)
369 if (assemblyName == null)
370 throw new ArgumentNullException ("assemblyName");
372 return Activator.CreateInstance (assemblyName, typeName);
375 public ObjectHandle CreateInstance (string assemblyName, string typeName, object[] activationAttributes)
377 if (assemblyName == null)
378 throw new ArgumentNullException ("assemblyName");
380 return Activator.CreateInstance (assemblyName, typeName, activationAttributes);
383 [Obsolete ("Use an overload that does not take an Evidence parameter")]
384 public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
385 Binder binder, object[] args, CultureInfo culture, object[] activationAttributes,
386 Evidence securityAttributes)
388 if (assemblyName == null)
389 throw new ArgumentNullException ("assemblyName");
391 return Activator.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
392 culture, activationAttributes, securityAttributes);
395 public object CreateInstanceAndUnwrap (string assemblyName, string typeName)
397 ObjectHandle oh = CreateInstance (assemblyName, typeName);
398 return (oh != null) ? oh.Unwrap () : null;
401 public object CreateInstanceAndUnwrap (string assemblyName, string typeName, object [] activationAttributes)
403 ObjectHandle oh = CreateInstance (assemblyName, typeName, activationAttributes);
404 return (oh != null) ? oh.Unwrap () : null;
407 [Obsolete ("Use an overload that does not take an Evidence parameter")]
408 public object CreateInstanceAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
409 BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
410 object[] activationAttributes, Evidence securityAttributes)
412 ObjectHandle oh = CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
413 culture, activationAttributes, securityAttributes);
414 return (oh != null) ? oh.Unwrap () : null;
417 public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
418 Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
420 if (assemblyName == null)
421 throw new ArgumentNullException ("assemblyName");
423 return Activator.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
424 culture, activationAttributes, null);
426 public object CreateInstanceAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
427 BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
428 object[] activationAttributes)
430 ObjectHandle oh = CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
431 culture, activationAttributes);
432 return (oh != null) ? oh.Unwrap () : null;
435 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
436 BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
437 object[] activationAttributes)
439 if (assemblyFile == null)
440 throw new ArgumentNullException ("assemblyFile");
442 return Activator.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args,
443 culture, activationAttributes, null);
446 public object CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, bool ignoreCase,
447 BindingFlags bindingAttr, Binder binder, object[] args,
448 CultureInfo culture, object[] activationAttributes)
450 ObjectHandle oh = CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args,
451 culture, activationAttributes);
453 return (oh != null) ? oh.Unwrap () : null;
456 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
458 if (assemblyFile == null)
459 throw new ArgumentNullException ("assemblyFile");
461 return Activator.CreateInstanceFrom (assemblyFile, typeName);
464 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, object[] activationAttributes)
466 if (assemblyFile == null)
467 throw new ArgumentNullException ("assemblyFile");
469 return Activator.CreateInstanceFrom (assemblyFile, typeName, activationAttributes);
472 [Obsolete ("Use an overload that does not take an Evidence parameter")]
473 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
474 BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
475 object[] activationAttributes, Evidence securityAttributes)
477 if (assemblyFile == null)
478 throw new ArgumentNullException ("assemblyFile");
480 return Activator.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args,
481 culture, activationAttributes, securityAttributes);
484 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName)
486 ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName);
487 return (oh != null) ? oh.Unwrap () : null;
490 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, object [] activationAttributes)
492 ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, activationAttributes);
493 return (oh != null) ? oh.Unwrap () : null;
496 [Obsolete ("Use an overload that does not take an Evidence parameter")]
497 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
498 BindingFlags bindingAttr, Binder binder, object[] args,
499 CultureInfo culture, object[] activationAttributes,
500 Evidence securityAttributes)
502 ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
503 culture, activationAttributes, securityAttributes);
505 return (oh != null) ? oh.Unwrap () : null;
508 #if !FULL_AOT_RUNTIME
509 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
511 return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
514 [Obsolete ("Declarative security for assembly level is no longer enforced")]
515 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence)
517 return DefineDynamicAssembly (name, access, null, evidence, null, null, null, false);
520 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir)
522 return DefineDynamicAssembly (name, access, dir, null, null, null, null, false);
525 [Obsolete ("Declarative security for assembly level is no longer enforced")]
526 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
529 return DefineDynamicAssembly (name, access, dir, evidence, null, null, null, false);
532 [Obsolete ("Declarative security for assembly level is no longer enforced")]
533 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
534 PermissionSet requiredPermissions,
535 PermissionSet optionalPermissions,
536 PermissionSet refusedPermissions)
538 return DefineDynamicAssembly (name, access, null, null, requiredPermissions, optionalPermissions,
539 refusedPermissions, false);
542 [Obsolete ("Declarative security for assembly level is no longer enforced")]
543 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence,
544 PermissionSet requiredPermissions,
545 PermissionSet optionalPermissions,
546 PermissionSet refusedPermissions)
548 return DefineDynamicAssembly (name, access, null, evidence, requiredPermissions, optionalPermissions,
549 refusedPermissions, false);
552 [Obsolete ("Declarative security for assembly level is no longer enforced")]
553 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
554 PermissionSet requiredPermissions,
555 PermissionSet optionalPermissions,
556 PermissionSet refusedPermissions)
558 return DefineDynamicAssembly (name, access, dir, null, requiredPermissions, optionalPermissions,
559 refusedPermissions, false);
562 [Obsolete ("Declarative security for assembly level is no longer enforced")]
563 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
565 PermissionSet requiredPermissions,
566 PermissionSet optionalPermissions,
567 PermissionSet refusedPermissions)
569 return DefineDynamicAssembly (name, access, dir, evidence, requiredPermissions, optionalPermissions,
570 refusedPermissions, false);
573 [Obsolete ("Declarative security for assembly level is no longer enforced")]
574 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
576 PermissionSet requiredPermissions,
577 PermissionSet optionalPermissions,
578 PermissionSet refusedPermissions, bool isSynchronized)
581 throw new ArgumentNullException ("name");
582 ValidateAssemblyName (name.Name);
584 // FIXME: examine all other parameters
586 AssemblyBuilder ab = new AssemblyBuilder (name, dir, access, false);
587 ab.AddPermissionRequests (requiredPermissions, optionalPermissions, refusedPermissions);
592 [Obsolete ("Declarative security for assembly level is no longer enforced")]
593 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
595 PermissionSet requiredPermissions,
596 PermissionSet optionalPermissions,
597 PermissionSet refusedPermissions, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
599 AssemblyBuilder ab = DefineDynamicAssembly (name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, isSynchronized);
600 if (assemblyAttributes != null)
601 foreach (CustomAttributeBuilder cb in assemblyAttributes) {
602 ab.SetCustomAttribute (cb);
608 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
610 return DefineDynamicAssembly (name, access, null, null, null, null, null, false, assemblyAttributes);
613 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
615 return DefineDynamicAssembly (name, access, dir, null, null, null, null, isSynchronized, assemblyAttributes);
618 [MonoLimitation ("The argument securityContextSource is ignored")]
619 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes, SecurityContextSource securityContextSource)
621 return DefineDynamicAssembly (name, access, assemblyAttributes);
624 internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
626 return new AssemblyBuilder (name, null, access, true);
631 // AppDomain.DoCallBack works because AppDomain is a MarshalByRefObject
632 // so, when you call AppDomain.DoCallBack, that's a remote call
634 public void DoCallBack (CrossAppDomainDelegate callBackDelegate)
636 if (callBackDelegate != null)
640 public int ExecuteAssembly (string assemblyFile)
642 return ExecuteAssembly (assemblyFile, (Evidence)null, null);
645 [Obsolete ("Use an overload that does not take an Evidence parameter")]
646 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity)
648 return ExecuteAssembly (assemblyFile, assemblySecurity, null);
651 [Obsolete ("Use an overload that does not take an Evidence parameter")]
652 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args)
654 Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity);
655 return ExecuteAssemblyInternal (a, args);
658 [Obsolete ("Use an overload that does not take an Evidence parameter")]
659 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
661 Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity, hashValue, hashAlgorithm);
662 return ExecuteAssemblyInternal (a, args);
666 public int ExecuteAssembly (string assemblyFile, string[] args)
668 Assembly a = Assembly.LoadFrom (assemblyFile, null);
669 return ExecuteAssemblyInternal (a, args);
672 public int ExecuteAssembly (string assemblyFile, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
674 Assembly a = Assembly.LoadFrom (assemblyFile, null, hashValue, hashAlgorithm);
675 return ExecuteAssemblyInternal (a, args);
678 int ExecuteAssemblyInternal (Assembly a, string[] args)
680 if (a.EntryPoint == null)
681 throw new MissingMethodException ("Entry point not found in assembly '" + a.FullName + "'.");
682 return ExecuteAssembly (a, args);
685 [MethodImplAttribute (MethodImplOptions.InternalCall)]
686 private extern int ExecuteAssembly (Assembly a, string[] args);
688 [MethodImplAttribute (MethodImplOptions.InternalCall)]
689 private extern Assembly [] GetAssemblies (bool refOnly);
691 public Assembly [] GetAssemblies ()
693 return GetAssemblies (false);
696 [MethodImplAttribute (MethodImplOptions.InternalCall)]
697 public extern object GetData (string name);
699 public new Type GetType()
701 return base.GetType ();
704 public override object InitializeLifetimeService ()
709 [MethodImplAttribute (MethodImplOptions.InternalCall)]
710 internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly);
712 public Assembly Load (AssemblyName assemblyRef)
714 return Load (assemblyRef, null);
717 internal Assembly LoadSatellite (AssemblyName assemblyRef, bool throwOnError)
719 if (assemblyRef == null)
720 throw new ArgumentNullException ("assemblyRef");
722 Assembly result = LoadAssembly (assemblyRef.FullName, null, false);
723 if (result == null && throwOnError)
724 throw new FileNotFoundException (null, assemblyRef.Name);
728 [Obsolete ("Use an overload that does not take an Evidence parameter")]
729 public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
731 if (assemblyRef == null)
732 throw new ArgumentNullException ("assemblyRef");
734 if (assemblyRef.Name == null || assemblyRef.Name.Length == 0) {
735 if (assemblyRef.CodeBase != null)
736 return Assembly.LoadFrom (assemblyRef.CodeBase, assemblySecurity);
738 throw new ArgumentException (Locale.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
741 Assembly assembly = LoadAssembly (assemblyRef.FullName, assemblySecurity, false);
742 if (assembly != null)
745 if (assemblyRef.CodeBase == null)
746 throw new FileNotFoundException (null, assemblyRef.Name);
748 string cb = assemblyRef.CodeBase;
749 if (cb.ToLower (CultureInfo.InvariantCulture).StartsWith ("file://"))
750 cb = new Mono.Security.Uri (cb).LocalPath;
753 assembly = Assembly.LoadFrom (cb, assemblySecurity);
755 throw new FileNotFoundException (null, assemblyRef.Name);
757 AssemblyName aname = assembly.GetName ();
758 // Name, version, culture, publickeytoken. Anything else?
759 if (assemblyRef.Name != aname.Name)
760 throw new FileNotFoundException (null, assemblyRef.Name);
762 if (assemblyRef.Version != null && assemblyRef.Version != new Version (0, 0, 0, 0) && assemblyRef.Version != aname.Version)
763 throw new FileNotFoundException (null, assemblyRef.Name);
765 if (assemblyRef.CultureInfo != null && assemblyRef.CultureInfo.Equals (aname))
766 throw new FileNotFoundException (null, assemblyRef.Name);
768 byte [] pt = assemblyRef.GetPublicKeyToken ();
769 if (pt != null && pt.Length != 0) {
770 byte [] loaded_pt = aname.GetPublicKeyToken ();
771 if (loaded_pt == null || (pt.Length != loaded_pt.Length))
772 throw new FileNotFoundException (null, assemblyRef.Name);
773 for (int i = pt.Length - 1; i >= 0; i--)
774 if (loaded_pt [i] != pt [i])
775 throw new FileNotFoundException (null, assemblyRef.Name);
780 public Assembly Load (string assemblyString)
782 return Load (assemblyString, null, false);
785 [Obsolete ("Use an overload that does not take an Evidence parameter")]
786 public Assembly Load (string assemblyString, Evidence assemblySecurity)
788 return Load (assemblyString, assemblySecurity, false);
791 internal Assembly Load (string assemblyString, Evidence assemblySecurity, bool refonly)
793 if (assemblyString == null)
794 throw new ArgumentNullException ("assemblyString");
796 if (assemblyString.Length == 0)
797 throw new ArgumentException ("assemblyString cannot have zero length");
799 Assembly assembly = LoadAssembly (assemblyString, assemblySecurity, refonly);
800 if (assembly == null)
801 throw new FileNotFoundException (null, assemblyString);
805 public Assembly Load (byte[] rawAssembly)
807 return Load (rawAssembly, null, null);
810 public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore)
812 return Load (rawAssembly, rawSymbolStore, null);
815 [MethodImplAttribute (MethodImplOptions.InternalCall)]
816 internal extern Assembly LoadAssemblyRaw (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence, bool refonly);
818 [Obsolete ("Use an overload that does not take an Evidence parameter")]
819 public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
821 return Load (rawAssembly, rawSymbolStore, securityEvidence, false);
824 internal Assembly Load (byte [] rawAssembly, byte [] rawSymbolStore, Evidence securityEvidence, bool refonly)
826 if (rawAssembly == null)
827 throw new ArgumentNullException ("rawAssembly");
829 Assembly assembly = LoadAssemblyRaw (rawAssembly, rawSymbolStore, securityEvidence, refonly);
830 assembly.FromByteArray = true;
833 [Obsolete ("AppDomain policy levels are obsolete")]
834 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
835 public void SetAppDomainPolicy (PolicyLevel domainPolicy)
837 if (domainPolicy == null)
838 throw new ArgumentNullException ("domainPolicy");
839 if (_granted != null) {
840 throw new PolicyException (Locale.GetText (
841 "An AppDomain policy is already specified."));
843 if (IsFinalizingForUnload ())
844 throw new AppDomainUnloadedException ();
846 PolicyStatement ps = domainPolicy.Resolve ((Evidence)_evidence);
847 _granted = ps.PermissionSet;
850 [Obsolete ("Use AppDomainSetup.SetCachePath")]
851 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
852 public void SetCachePath (string path)
854 SetupInformationNoCopy.CachePath = path;
857 [SecurityPermission (SecurityAction.Demand, ControlPrincipal = true)]
858 public void SetPrincipalPolicy (PrincipalPolicy policy)
860 if (IsFinalizingForUnload ())
861 throw new AppDomainUnloadedException ();
864 _principalPolicy = (int)policy;
866 _principalPolicy = policy;
871 [Obsolete ("Use AppDomainSetup.ShadowCopyFiles")]
872 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
873 public void SetShadowCopyFiles()
875 SetupInformationNoCopy.ShadowCopyFiles = "true";
878 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
879 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
880 public void SetShadowCopyPath (string path)
882 SetupInformationNoCopy.ShadowCopyDirectories = path;
885 [SecurityPermission (SecurityAction.Demand, ControlPrincipal = true)]
886 public void SetThreadPrincipal (IPrincipal principal)
888 if (principal == null)
889 throw new ArgumentNullException ("principal");
890 if (_principal != null)
891 throw new PolicyException (Locale.GetText ("principal already present."));
892 if (IsFinalizingForUnload ())
893 throw new AppDomainUnloadedException ();
895 _principal = principal;
898 [MethodImplAttribute (MethodImplOptions.InternalCall)]
899 private static extern AppDomain InternalSetDomainByID (int domain_id);
901 // Changes the active domain and returns the old domain
902 [MethodImplAttribute (MethodImplOptions.InternalCall)]
903 private static extern AppDomain InternalSetDomain (AppDomain context);
905 // Notifies the runtime that this thread references 'domain'.
906 [MethodImplAttribute (MethodImplOptions.InternalCall)]
907 internal static extern void InternalPushDomainRef (AppDomain domain);
909 [MethodImplAttribute (MethodImplOptions.InternalCall)]
910 internal static extern void InternalPushDomainRefByID (int domain_id);
912 // Undoes the effect of the last PushDomainRef call
913 [MethodImplAttribute (MethodImplOptions.InternalCall)]
914 internal static extern void InternalPopDomainRef ();
916 // Changes the active context and returns the old context
917 [MethodImplAttribute (MethodImplOptions.InternalCall)]
918 internal static extern Context InternalSetContext (Context context);
920 // Returns the current context
921 [MethodImplAttribute (MethodImplOptions.InternalCall)]
922 internal static extern Context InternalGetContext ();
924 // Returns the current context
925 [MethodImplAttribute (MethodImplOptions.InternalCall)]
926 internal static extern Context InternalGetDefaultContext ();
928 [MethodImplAttribute (MethodImplOptions.InternalCall)]
929 internal static extern string InternalGetProcessGuid (string newguid);
931 // This method is handled specially by the runtime
932 // It is the only managed method which is allowed to set the current
934 internal static object InvokeInDomain (AppDomain domain, MethodInfo method, object obj, object [] args)
936 AppDomain current = CurrentDomain;
941 InternalPushDomainRef (domain);
943 InternalSetDomain (domain);
944 object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
950 InternalSetDomain (current);
952 InternalPopDomainRef ();
956 internal static object InvokeInDomainByID (int domain_id, MethodInfo method, object obj, object [] args)
958 AppDomain current = CurrentDomain;
963 InternalPushDomainRefByID (domain_id);
965 InternalSetDomainByID (domain_id);
966 object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
972 InternalSetDomain (current);
974 InternalPopDomainRef ();
978 internal static String GetProcessGuid ()
980 if (_process_guid == null) {
981 _process_guid = InternalGetProcessGuid (Guid.NewGuid().ToString ());
983 return _process_guid;
986 public static AppDomain CreateDomain (string friendlyName)
988 return CreateDomain (friendlyName, null, null);
991 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo)
993 return CreateDomain (friendlyName, securityInfo, null);
996 [MethodImplAttribute (MethodImplOptions.InternalCall)]
997 private static extern AppDomain createDomain (string friendlyName, AppDomainSetup info);
999 [MonoLimitationAttribute ("Currently it does not allow the setup in the other domain")]
1000 [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
1001 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info)
1003 if (friendlyName == null)
1004 throw new System.ArgumentNullException ("friendlyName");
1006 AppDomain def = AppDomain.DefaultDomain;
1008 // if null, get default domain's SetupInformation
1010 info = new AppDomainSetup (); // we're default!
1012 info = def.SetupInformation;
1015 info = new AppDomainSetup (info); // copy
1017 // todo: allow setup in the other domain
1019 if (!info.Equals (def.SetupInformation)) {
1020 // If not specified use default domain's app base.
1021 if (info.ApplicationBase == null)
1022 info.ApplicationBase = def.SetupInformation.ApplicationBase;
1023 if (info.ConfigurationFile == null)
1024 info.ConfigurationFile = Path.GetFileName (def.SetupInformation.ConfigurationFile);
1026 } else if (info.ConfigurationFile == null)
1027 info.ConfigurationFile = "[I don't have a config file]";
1030 if (info.AppDomainInitializer != null) {
1031 if (!info.AppDomainInitializer.Method.IsStatic)
1032 throw new ArgumentException ("Non-static methods cannot be invoked as an appdomain initializer");
1036 info.SerializeNonPrimitives ();
1038 AppDomain ad = (AppDomain) RemotingServices.GetDomainProxy (createDomain (friendlyName, info));
1039 if (securityInfo == null) {
1040 // get default domain's Evidence (unless we're are the default!)
1042 ad._evidence = null; // we'll get them later (GetEntryAssembly)
1044 ad._evidence = def.Evidence; // new (shallow) copy
1047 ad._evidence = new Evidence (securityInfo); // copy
1050 if (info.AppDomainInitializer != null) {
1051 Loader loader = new Loader (
1052 info.AppDomainInitializer.Method.DeclaringType.Assembly.Location);
1053 ad.DoCallBack (loader.Load);
1055 Initializer initializer = new Initializer (
1056 info.AppDomainInitializer,
1057 info.AppDomainInitializerArguments);
1058 ad.DoCallBack (initializer.Initialize);
1071 public Loader (string assembly)
1073 this.assembly = assembly;
1078 Assembly.LoadFrom (assembly);
1085 AppDomainInitializer initializer;
1086 string [] arguments;
1088 public Initializer (AppDomainInitializer initializer, string [] arguments)
1090 this.initializer = initializer;
1091 this.arguments = arguments;
1094 public void Initialize ()
1096 initializer (arguments);
1101 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath,
1102 string appRelativeSearchPath, bool shadowCopyFiles)
1104 return CreateDomain (friendlyName, securityInfo, CreateDomainSetup (appBasePath, appRelativeSearchPath, shadowCopyFiles));
1108 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info,
1109 PermissionSet grantSet, params StrongName [] fullTrustAssemblies)
1112 throw new ArgumentNullException ("info");
1114 info.ApplicationTrust = new ApplicationTrust (grantSet, fullTrustAssemblies ?? EmptyArray<StrongName>.Value);
1115 return CreateDomain (friendlyName, securityInfo, info);
1119 static AppDomainSetup CreateDomainSetup (string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles)
1121 AppDomainSetup info = new AppDomainSetup ();
1123 info.ApplicationBase = appBasePath;
1124 info.PrivateBinPath = appRelativeSearchPath;
1126 if (shadowCopyFiles)
1127 info.ShadowCopyFiles = "true";
1129 info.ShadowCopyFiles = "false";
1134 [MethodImplAttribute (MethodImplOptions.InternalCall)]
1135 private static extern bool InternalIsFinalizingForUnload (int domain_id);
1137 public bool IsFinalizingForUnload()
1139 return InternalIsFinalizingForUnload (getDomainID ());
1142 [MethodImplAttribute (MethodImplOptions.InternalCall)]
1143 static extern void InternalUnload (int domain_id);
1145 // We do this because if the domain is a transparant proxy this
1146 // will still return the correct domain id.
1147 private int getDomainID ()
1149 return Thread.GetDomainID ();
1152 [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
1153 [ReliabilityContractAttribute (Consistency.MayCorruptAppDomain, Cer.MayFail)]
1154 public static void Unload (AppDomain domain)
1157 throw new ArgumentNullException ("domain");
1159 InternalUnload (domain.getDomainID());
1162 [MethodImplAttribute (MethodImplOptions.InternalCall)]
1163 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1164 public extern void SetData (string name, object data);
1166 [MonoLimitation ("The permission field is ignored")]
1167 public void SetData (string name, object data, IPermission permission)
1169 SetData (name, data);
1173 [Obsolete ("Use AppDomainSetup.DynamicBase")]
1174 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1175 public void SetDynamicBase (string path)
1177 SetupInformationNoCopy.DynamicBase = path;
1181 [Obsolete ("AppDomain.GetCurrentThreadId has been deprecated"
1182 + " because it does not provide a stable Id when managed"
1183 + " threads are running on fibers (aka lightweight"
1184 + " threads). To get a stable identifier for a managed"
1185 + " thread, use the ManagedThreadId property on Thread.'")]
1186 public static int GetCurrentThreadId ()
1188 return Thread.CurrentThreadId;
1191 public override string ToString ()
1193 return getFriendlyName ();
1196 private static void ValidateAssemblyName (string name)
1198 if (name == null || name.Length == 0)
1199 throw new ArgumentException ("The Name of " +
1200 "AssemblyName cannot be null or a " +
1201 "zero-length string.");
1203 bool isValid = true;
1205 for (int i = 0; i < name.Length; i++) {
1208 // do not allow leading whitespace
1209 if (i == 0 && char.IsWhiteSpace (c)) {
1214 // do not allow /,\ or : in name
1215 if (c == '/' || c == '\\' || c == ':') {
1222 throw new ArgumentException ("The Name of " +
1223 "AssemblyName cannot start with " +
1224 "whitespace, or contain '/', '\\' " +
1228 // The following methods are called from the runtime. Don't change signatures.
1229 #pragma warning disable 169
1230 private void DoAssemblyLoad (Assembly assembly)
1232 if (AssemblyLoad == null)
1235 AssemblyLoad (this, new AssemblyLoadEventArgs (assembly));
1238 private Assembly DoAssemblyResolve (string name, Assembly requestingAssembly, bool refonly)
1240 ResolveEventHandler del;
1243 del = ReflectionOnlyAssemblyResolve;
1245 del = AssemblyResolve;
1247 del = AssemblyResolve;
1252 /* Prevent infinite recursion */
1253 Dictionary<string, object> ht;
1255 ht = assembly_resolve_in_progress_refonly;
1257 ht = new Dictionary<string, object> ();
1258 assembly_resolve_in_progress_refonly = ht;
1261 ht = assembly_resolve_in_progress;
1263 ht = new Dictionary<string, object> ();
1264 assembly_resolve_in_progress = ht;
1268 if (ht.ContainsKey (name))
1273 Delegate[] invocation_list = del.GetInvocationList ();
1275 foreach (Delegate eh in invocation_list) {
1276 ResolveEventHandler handler = (ResolveEventHandler) eh;
1277 Assembly assembly = handler (this, new ResolveEventArgs (name, requestingAssembly));
1278 if (assembly != null)
1288 internal Assembly DoTypeResolve (Object name_or_tb)
1290 if (TypeResolve == null)
1295 #if !FULL_AOT_RUNTIME
1296 if (name_or_tb is TypeBuilder)
1297 name = ((TypeBuilder) name_or_tb).FullName;
1300 name = (string) name_or_tb;
1302 /* Prevent infinite recursion */
1303 var ht = type_resolve_in_progress;
1305 type_resolve_in_progress = ht = new Dictionary<string, object> ();
1308 if (ht.ContainsKey (name))
1314 foreach (Delegate d in TypeResolve.GetInvocationList ()) {
1315 ResolveEventHandler eh = (ResolveEventHandler) d;
1316 Assembly assembly = eh (this, new ResolveEventArgs (name));
1317 if (assembly != null)
1327 internal Assembly DoResourceResolve (string name, Assembly requesting) {
1328 if (ResourceResolve == null)
1331 Delegate[] invocation_list = ResourceResolve.GetInvocationList ();
1333 foreach (Delegate eh in invocation_list) {
1334 ResolveEventHandler handler = (ResolveEventHandler) eh;
1335 Assembly assembly = handler (this, new ResolveEventArgs (name, requesting));
1336 if (assembly != null)
1342 private void DoDomainUnload ()
1344 if (DomainUnload != null)
1345 DomainUnload(this, null);
1348 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1349 internal extern void DoUnhandledException (Exception e);
1351 internal void DoUnhandledException (UnhandledExceptionEventArgs args) {
1352 if (UnhandledException != null)
1353 UnhandledException (this, args);
1356 internal byte[] GetMarshalledDomainObjRef ()
1358 ObjRef oref = RemotingServices.Marshal (AppDomain.CurrentDomain, null, typeof (AppDomain));
1359 return CADSerializer.SerializeObject (oref).GetBuffer();
1362 internal void ProcessMessageInDomain (byte[] arrRequest, CADMethodCallMessage cadMsg,
1363 out byte[] arrResponse, out CADMethodReturnMessage cadMrm)
1367 if (null != arrRequest)
1368 reqDomMsg = CADSerializer.DeserializeMessage (new MemoryStream(arrRequest), null);
1370 reqDomMsg = new MethodCall (cadMsg);
1372 IMessage retDomMsg = ChannelServices.SyncDispatchMessage (reqDomMsg);
1374 cadMrm = CADMethodReturnMessage.Create (retDomMsg);
1375 if (null == cadMrm) {
1376 arrResponse = CADSerializer.SerializeMessage (retDomMsg).GetBuffer();
1382 #pragma warning restore 169
1384 // End of methods called from the runtime
1386 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1387 public event AssemblyLoadEventHandler AssemblyLoad;
1389 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1390 public event ResolveEventHandler AssemblyResolve;
1392 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1393 public event EventHandler DomainUnload;
1395 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1396 public event EventHandler ProcessExit;
1398 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1399 public event ResolveEventHandler ResourceResolve;
1401 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1402 public event ResolveEventHandler TypeResolve;
1404 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1405 public event UnhandledExceptionEventHandler UnhandledException;
1407 public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException;
1410 public bool IsHomogenous {
1411 get { return true; }
1415 public bool IsFullyTrusted {
1416 get { return true; }
1419 #pragma warning disable 649
1421 private AppDomainManager _domain_manager;
1423 object _domain_manager;
1425 #pragma warning restore 649
1428 public AppDomainManager DomainManager {
1429 get { return (AppDomainManager)_domain_manager; }
1433 public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
1436 #pragma warning disable 649
1438 private object _activation;
1439 private object _applicationIdentity;
1441 private ActivationContext _activation;
1442 private ApplicationIdentity _applicationIdentity;
1444 #pragma warning restore 649
1448 public ActivationContext ActivationContext {
1449 get { return (ActivationContext)_activation; }
1452 public ApplicationIdentity ApplicationIdentity {
1453 get { return (ApplicationIdentity)_applicationIdentity; }
1457 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
1458 get { return getDomainID (); }
1463 [MonoTODO ("This routine only returns the parameter currently")]
1464 [ComVisible (false)]
1465 public string ApplyPolicy (string assemblyName)
1467 if (assemblyName == null)
1468 throw new ArgumentNullException ("assemblyName");
1469 if (assemblyName.Length == 0) // String.Empty
1470 throw new ArgumentException ("assemblyName");
1471 return assemblyName;
1476 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath,
1477 string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs)
1479 AppDomainSetup info = CreateDomainSetup (appBasePath, appRelativeSearchPath, shadowCopyFiles);
1481 info.AppDomainInitializerArguments = adInitArgs;
1482 info.AppDomainInitializer = adInit;
1484 return CreateDomain (friendlyName, securityInfo, info);
1487 public int ExecuteAssemblyByName (string assemblyName)
1489 return ExecuteAssemblyByName (assemblyName, (Evidence)null, null);
1492 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1493 public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity)
1495 return ExecuteAssemblyByName (assemblyName, assemblySecurity, null);
1498 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1499 public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity, params string[] args)
1501 Assembly a = Assembly.Load (assemblyName, assemblySecurity);
1503 return ExecuteAssemblyInternal (a, args);
1506 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1507 public int ExecuteAssemblyByName (AssemblyName assemblyName, Evidence assemblySecurity, params string[] args)
1509 Assembly a = Assembly.Load (assemblyName, assemblySecurity);
1511 return ExecuteAssemblyInternal (a, args);
1514 public int ExecuteAssemblyByName (string assemblyName, params string[] args)
1516 Assembly a = Assembly.Load (assemblyName, null);
1518 return ExecuteAssemblyInternal (a, args);
1521 public int ExecuteAssemblyByName (AssemblyName assemblyName, params string[] args)
1523 Assembly a = Assembly.Load (assemblyName, null);
1525 return ExecuteAssemblyInternal (a, args);
1528 public bool IsDefaultAppDomain ()
1530 return Object.ReferenceEquals (this, DefaultDomain);
1533 public Assembly[] ReflectionOnlyGetAssemblies ()
1535 return GetAssemblies (true);
1539 void _AppDomain.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
1541 throw new NotImplementedException ();
1544 void _AppDomain.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
1546 throw new NotImplementedException ();
1549 void _AppDomain.GetTypeInfoCount (out uint pcTInfo)
1551 throw new NotImplementedException ();
1554 void _AppDomain.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
1555 IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
1557 throw new NotImplementedException ();
1561 List<string> compatibility_switch;
1563 public bool? IsCompatibilitySwitchSet (string value)
1566 throw new ArgumentNullException ("value");
1568 // default (at least for SL4) is to return false for unknown values (can't get a null out of it)
1569 return ((compatibility_switch != null) && compatibility_switch.Contains (value));
1572 internal void SetCompatibilitySwitch (string value)
1574 if (compatibility_switch == null)
1575 compatibility_switch = new List<string> ();
1576 compatibility_switch.Add (value);
1579 [MonoTODO ("Currently always returns false")]
1580 public static bool MonitoringIsEnabled {
1581 get { return false; }
1582 set { throw new NotImplementedException (); }
1586 public long MonitoringSurvivedMemorySize {
1587 get { throw new NotImplementedException (); }
1591 public static long MonitoringSurvivedProcessMemorySize {
1592 get { throw new NotImplementedException (); }
1596 public long MonitoringTotalAllocatedMemorySize {
1597 get { throw new NotImplementedException (); }
1601 public TimeSpan MonitoringTotalProcessorTime {
1602 get { throw new NotImplementedException (); }