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)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System
.Collections
;
36 using System
.Globalization
;
38 using System
.Reflection
;
39 using System
.Reflection
.Emit
;
40 using System
.Threading
;
41 using System
.Runtime
.CompilerServices
;
42 using System
.Runtime
.InteropServices
;
43 using System
.Runtime
.Remoting
;
44 using System
.Runtime
.Remoting
.Contexts
;
45 using System
.Runtime
.Remoting
.Channels
;
46 using System
.Runtime
.Remoting
.Messaging
;
47 using System
.Security
;
48 using System
.Security
.Permissions
;
49 using System
.Security
.Policy
;
50 using System
.Security
.Principal
;
51 using System
.Configuration
.Assemblies
;
53 using System
.Collections
.Generic
;
54 using System
.Runtime
.ConstrainedExecution
;
61 [ComDefaultInterface (typeof (_AppDomain
))]
63 [ClassInterface(ClassInterfaceType
.None
)]
65 public sealed class AppDomain
: MarshalByRefObject
{
67 public sealed class AppDomain
: MarshalByRefObject
, _AppDomain
, IEvidenceFactory
{
69 #pragma warning disable 169
70 #region Sync with object-internals.h
71 IntPtr _mono_app_domain
;
73 #pragma warning restore 169
74 static string _process_guid
;
77 static Hashtable type_resolve_in_progress
;
80 static Hashtable assembly_resolve_in_progress
;
83 static Hashtable assembly_resolve_in_progress_refonly
;
86 private Evidence _evidence
;
87 private PermissionSet _granted
;
90 private PrincipalPolicy _principalPolicy
;
93 private static IPrincipal _principal
;
95 static AppDomain default_domain
;
101 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
102 private extern AppDomainSetup
getSetup ();
107 AppDomainSetup SetupInformationNoCopy
{
108 get { return getSetup (); }
111 public AppDomainSetup SetupInformation
{
113 AppDomainSetup setup
= getSetup ();
114 return new AppDomainSetup (setup
);
120 public ApplicationTrust ApplicationTrust
{
121 get { throw new NotImplementedException (); }
125 public string BaseDirectory
{
127 string path
= SetupInformationNoCopy
.ApplicationBase
;
128 if (SecurityManager
.SecurityEnabled
&& (path
!= null) && (path
.Length
> 0)) {
129 // we cannot divulge local file informations
130 new FileIOPermission (FileIOPermissionAccess
.PathDiscovery
, path
).Demand ();
136 public string RelativeSearchPath
{
138 string path
= SetupInformationNoCopy
.PrivateBinPath
;
139 if (SecurityManager
.SecurityEnabled
&& (path
!= null) && (path
.Length
> 0)) {
140 // we cannot divulge local file informations
141 new FileIOPermission (FileIOPermissionAccess
.PathDiscovery
, path
).Demand ();
147 public string DynamicDirectory
{
149 AppDomainSetup setup
= SetupInformationNoCopy
;
150 if (setup
.DynamicBase
== null)
153 string path
= Path
.Combine (setup
.DynamicBase
, setup
.ApplicationName
);
154 if (SecurityManager
.SecurityEnabled
&& (path
!= null) && (path
.Length
> 0)) {
155 // we cannot divulge local file informations
156 new FileIOPermission (FileIOPermissionAccess
.PathDiscovery
, path
).Demand ();
162 public bool ShadowCopyFiles
{
164 return (SetupInformationNoCopy
.ShadowCopyFiles
== "true");
169 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
170 private extern string getFriendlyName ();
172 public string FriendlyName
{
174 return getFriendlyName ();
178 public Evidence Evidence
{
180 // if the host (runtime) hasn't provided it's own evidence...
181 if (_evidence
== null) {
182 // ... we will provide our own
184 // the executed assembly from the "default" appdomain
185 // or null if we're not in the default appdomain or
186 // if there is no entry assembly (embedded mono)
187 Assembly a
= Assembly
.GetEntryAssembly ();
189 if (this == DefaultDomain
)
191 return new Evidence ();
193 _evidence
= AppDomain
.DefaultDomain
.Evidence
;
195 _evidence
= Evidence
.GetDefaultHostEvidence (a
);
199 return new Evidence (_evidence
); // return a copy
203 internal IPrincipal DefaultPrincipal
{
205 if (_principal
== null) {
206 switch (_principalPolicy
) {
207 case PrincipalPolicy
.UnauthenticatedPrincipal
:
208 _principal
= new GenericPrincipal (
209 new GenericIdentity (String
.Empty
, String
.Empty
), null);
211 case PrincipalPolicy
.WindowsPrincipal
:
212 _principal
= new WindowsPrincipal (WindowsIdentity
.GetCurrent ());
220 // for AppDomain there is only an allowed (i.e. granted) set
221 // http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondetermininggrantedpermissions.asp
222 internal PermissionSet GrantedPermissionSet
{
223 get { return _granted; }
226 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
227 private static extern AppDomain
getCurDomain ();
229 public static AppDomain CurrentDomain
{
231 return getCurDomain ();
235 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
236 private static extern AppDomain
getRootDomain ();
238 internal static AppDomain DefaultDomain
{
240 if (default_domain
== null) {
241 AppDomain rd
= getRootDomain ();
242 if (rd
== CurrentDomain
)
245 default_domain
= (AppDomain
) RemotingServices
.GetDomainProxy (rd
);
247 return default_domain
;
253 [Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
254 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
255 public void AppendPrivatePath (string path
)
257 if (path
== null || path
.Length
== 0)
260 AppDomainSetup setup
= SetupInformationNoCopy
;
262 string pp
= setup
.PrivateBinPath
;
263 if (pp
== null || pp
.Length
== 0) {
264 setup
.PrivateBinPath
= path
;
269 if (pp
[pp
.Length
- 1] != Path
.PathSeparator
)
270 pp
+= Path
.PathSeparator
;
272 setup
.PrivateBinPath
= pp
+ path
;
275 [Obsolete ("AppDomain.ClearPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
276 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
277 public void ClearPrivatePath ()
279 SetupInformationNoCopy
.PrivateBinPath
= String
.Empty
;
282 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
283 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
284 public void ClearShadowCopyPath ()
286 SetupInformationNoCopy
.ShadowCopyDirectories
= String
.Empty
;
290 public ObjectHandle
CreateComInstanceFrom (string assemblyName
, string typeName
)
292 return Activator
.CreateComInstanceFrom (assemblyName
, typeName
);
295 public ObjectHandle
CreateComInstanceFrom (string assemblyFile
, string typeName
,
296 byte [] hashValue
, AssemblyHashAlgorithm hashAlgorithm
)
298 return Activator
.CreateComInstanceFrom (assemblyFile
, typeName
, hashValue
,hashAlgorithm
);
302 public ObjectHandle
CreateInstance (string assemblyName
, string typeName
)
304 if (assemblyName
== null)
305 throw new ArgumentNullException ("assemblyName");
307 return Activator
.CreateInstance (assemblyName
, typeName
);
310 public ObjectHandle
CreateInstance (string assemblyName
, string typeName
, object[] activationAttributes
)
312 if (assemblyName
== null)
313 throw new ArgumentNullException ("assemblyName");
315 return Activator
.CreateInstance (assemblyName
, typeName
, activationAttributes
);
319 [Obsolete ("Use an overload that does not take an Evidence parameter")]
321 public ObjectHandle
CreateInstance (string assemblyName
, string typeName
, bool ignoreCase
, BindingFlags bindingAttr
,
322 Binder binder
, object[] args
, CultureInfo culture
, object[] activationAttributes
,
323 Evidence securityAttributes
)
325 if (assemblyName
== null)
326 throw new ArgumentNullException ("assemblyName");
328 return Activator
.CreateInstance (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
329 culture
, activationAttributes
, securityAttributes
);
332 public object CreateInstanceAndUnwrap (string assemblyName
, string typeName
)
334 ObjectHandle oh
= CreateInstance (assemblyName
, typeName
);
335 return (oh
!= null) ? oh
.Unwrap () : null;
338 public object CreateInstanceAndUnwrap (string assemblyName
, string typeName
, object [] activationAttributes
)
340 ObjectHandle oh
= CreateInstance (assemblyName
, typeName
, activationAttributes
);
341 return (oh
!= null) ? oh
.Unwrap () : null;
345 [Obsolete ("Use an overload that does not take an Evidence parameter")]
347 public object CreateInstanceAndUnwrap (string assemblyName
, string typeName
, bool ignoreCase
,
348 BindingFlags bindingAttr
, Binder binder
, object[] args
, CultureInfo culture
,
349 object[] activationAttributes
, Evidence securityAttributes
)
351 ObjectHandle oh
= CreateInstance (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
352 culture
, activationAttributes
, securityAttributes
);
353 return (oh
!= null) ? oh
.Unwrap () : null;
357 public ObjectHandle
CreateInstance (string assemblyName
, string typeName
, bool ignoreCase
, BindingFlags bindingAttr
,
358 Binder binder
, object[] args
, CultureInfo culture
, object[] activationAttributes
)
360 if (assemblyName
== null)
361 throw new ArgumentNullException ("assemblyName");
363 return Activator
.CreateInstance (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
364 culture
, activationAttributes
, null);
366 public object CreateInstanceAndUnwrap (string assemblyName
, string typeName
, bool ignoreCase
,
367 BindingFlags bindingAttr
, Binder binder
, object[] args
, CultureInfo culture
,
368 object[] activationAttributes
)
370 ObjectHandle oh
= CreateInstance (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
371 culture
, activationAttributes
);
372 return (oh
!= null) ? oh
.Unwrap () : null;
375 public ObjectHandle
CreateInstanceFrom (string assemblyFile
, string typeName
, bool ignoreCase
,
376 BindingFlags bindingAttr
, Binder binder
, object[] args
, CultureInfo culture
,
377 object[] activationAttributes
)
379 if (assemblyFile
== null)
380 throw new ArgumentNullException ("assemblyFile");
382 return Activator
.CreateInstanceFrom (assemblyFile
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
383 culture
, activationAttributes
, null);
386 public object CreateInstanceFromAndUnwrap (string assemblyName
, string typeName
, bool ignoreCase
,
387 BindingFlags bindingAttr
, Binder binder
, object[] args
,
388 CultureInfo culture
, object[] activationAttributes
)
390 ObjectHandle oh
= CreateInstanceFrom (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
391 culture
, activationAttributes
);
393 return (oh
!= null) ? oh
.Unwrap () : null;
397 public ObjectHandle
CreateInstanceFrom (string assemblyFile
, string typeName
)
399 if (assemblyFile
== null)
400 throw new ArgumentNullException ("assemblyFile");
402 return Activator
.CreateInstanceFrom (assemblyFile
, typeName
);
405 public ObjectHandle
CreateInstanceFrom (string assemblyFile
, string typeName
, object[] activationAttributes
)
407 if (assemblyFile
== null)
408 throw new ArgumentNullException ("assemblyFile");
410 return Activator
.CreateInstanceFrom (assemblyFile
, typeName
, activationAttributes
);
414 [Obsolete ("Use an overload that does not take an Evidence parameter")]
416 public ObjectHandle
CreateInstanceFrom (string assemblyFile
, string typeName
, bool ignoreCase
,
417 BindingFlags bindingAttr
, Binder binder
, object[] args
, CultureInfo culture
,
418 object[] activationAttributes
, Evidence securityAttributes
)
420 if (assemblyFile
== null)
421 throw new ArgumentNullException ("assemblyFile");
423 return Activator
.CreateInstanceFrom (assemblyFile
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
424 culture
, activationAttributes
, securityAttributes
);
427 public object CreateInstanceFromAndUnwrap (string assemblyName
, string typeName
)
429 ObjectHandle oh
= CreateInstanceFrom (assemblyName
, typeName
);
430 return (oh
!= null) ? oh
.Unwrap () : null;
433 public object CreateInstanceFromAndUnwrap (string assemblyName
, string typeName
, object [] activationAttributes
)
435 ObjectHandle oh
= CreateInstanceFrom (assemblyName
, typeName
, activationAttributes
);
436 return (oh
!= null) ? oh
.Unwrap () : null;
440 [Obsolete ("Use an overload that does not take an Evidence parameter")]
442 public object CreateInstanceFromAndUnwrap (string assemblyName
, string typeName
, bool ignoreCase
,
443 BindingFlags bindingAttr
, Binder binder
, object[] args
,
444 CultureInfo culture
, object[] activationAttributes
,
445 Evidence securityAttributes
)
447 ObjectHandle oh
= CreateInstanceFrom (assemblyName
, typeName
, ignoreCase
, bindingAttr
, binder
, args
,
448 culture
, activationAttributes
, securityAttributes
);
450 return (oh
!= null) ? oh
.Unwrap () : null;
455 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
)
457 return DefineDynamicAssembly (name
, access
, null, null, null, null, null, false);
461 [Obsolete ("Declarative security for assembly level is no longer enforced")]
463 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, Evidence evidence
)
465 return DefineDynamicAssembly (name
, access
, null, evidence
, null, null, null, false);
468 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
)
470 return DefineDynamicAssembly (name
, access
, dir
, null, null, null, null, false);
474 [Obsolete ("Declarative security for assembly level is no longer enforced")]
476 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
,
479 return DefineDynamicAssembly (name
, access
, dir
, evidence
, null, null, null, false);
483 [Obsolete ("Declarative security for assembly level is no longer enforced")]
485 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
,
486 PermissionSet requiredPermissions
,
487 PermissionSet optionalPermissions
,
488 PermissionSet refusedPermissions
)
490 return DefineDynamicAssembly (name
, access
, null, null, requiredPermissions
, optionalPermissions
,
491 refusedPermissions
, false);
495 [Obsolete ("Declarative security for assembly level is no longer enforced")]
497 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, Evidence evidence
,
498 PermissionSet requiredPermissions
,
499 PermissionSet optionalPermissions
,
500 PermissionSet refusedPermissions
)
502 return DefineDynamicAssembly (name
, access
, null, evidence
, requiredPermissions
, optionalPermissions
,
503 refusedPermissions
, false);
507 [Obsolete ("Declarative security for assembly level is no longer enforced")]
509 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
,
510 PermissionSet requiredPermissions
,
511 PermissionSet optionalPermissions
,
512 PermissionSet refusedPermissions
)
514 return DefineDynamicAssembly (name
, access
, dir
, null, requiredPermissions
, optionalPermissions
,
515 refusedPermissions
, false);
519 [Obsolete ("Declarative security for assembly level is no longer enforced")]
521 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
,
523 PermissionSet requiredPermissions
,
524 PermissionSet optionalPermissions
,
525 PermissionSet refusedPermissions
)
527 return DefineDynamicAssembly (name
, access
, dir
, evidence
, requiredPermissions
, optionalPermissions
,
528 refusedPermissions
, false);
532 [Obsolete ("Declarative security for assembly level is no longer enforced")]
534 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
,
536 PermissionSet requiredPermissions
,
537 PermissionSet optionalPermissions
,
538 PermissionSet refusedPermissions
, bool isSynchronized
)
541 throw new ArgumentNullException ("name");
542 ValidateAssemblyName (name
.Name
);
544 // FIXME: examine all other parameters
546 AssemblyBuilder ab
= new AssemblyBuilder (name
, dir
, access
, false);
547 ab
.AddPermissionRequests (requiredPermissions
, optionalPermissions
, refusedPermissions
);
553 [Obsolete ("Declarative security for assembly level is no longer enforced")]
555 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
,
557 PermissionSet requiredPermissions
,
558 PermissionSet optionalPermissions
,
559 PermissionSet refusedPermissions
, bool isSynchronized
, IEnumerable
<CustomAttributeBuilder
> assemblyAttributes
)
561 AssemblyBuilder ab
= DefineDynamicAssembly (name
, access
, dir
, evidence
, requiredPermissions
, optionalPermissions
, refusedPermissions
, isSynchronized
);
562 if (assemblyAttributes
!= null)
563 foreach (CustomAttributeBuilder cb
in assemblyAttributes
) {
564 ab
.SetCustomAttribute (cb
);
570 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, IEnumerable
<CustomAttributeBuilder
> assemblyAttributes
)
572 return DefineDynamicAssembly (name
, access
, null, null, null, null, null, false, assemblyAttributes
);
576 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, string dir
, bool isSynchronized
, IEnumerable
<CustomAttributeBuilder
> assemblyAttributes
)
578 return DefineDynamicAssembly (name
, access
, dir
, null, null, null, null, isSynchronized
, assemblyAttributes
);
581 [MonoLimitation ("The argument securityContextSource is ignored")]
582 public AssemblyBuilder
DefineDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
, IEnumerable
<CustomAttributeBuilder
> assemblyAttributes
, SecurityContextSource securityContextSource
)
584 return DefineDynamicAssembly (name
, access
, assemblyAttributes
);
588 internal AssemblyBuilder
DefineInternalDynamicAssembly (AssemblyName name
, AssemblyBuilderAccess access
)
590 return new AssemblyBuilder (name
, null, access
, true);
594 // AppDomain.DoCallBack works because AppDomain is a MarshalByRefObject
595 // so, when you call AppDomain.DoCallBack, that's a remote call
597 public void DoCallBack (CrossAppDomainDelegate callBackDelegate
)
599 if (callBackDelegate
!= null)
603 public int ExecuteAssembly (string assemblyFile
)
605 return ExecuteAssembly (assemblyFile
, (Evidence
)null, null);
609 [Obsolete ("Use an overload that does not take an Evidence parameter")]
611 public int ExecuteAssembly (string assemblyFile
, Evidence assemblySecurity
)
613 return ExecuteAssembly (assemblyFile
, assemblySecurity
, null);
617 [Obsolete ("Use an overload that does not take an Evidence parameter")]
619 public int ExecuteAssembly (string assemblyFile
, Evidence assemblySecurity
, string[] args
)
621 Assembly a
= Assembly
.LoadFrom (assemblyFile
, assemblySecurity
);
622 return ExecuteAssemblyInternal (a
, args
);
626 [Obsolete ("Use an overload that does not take an Evidence parameter")]
628 public int ExecuteAssembly (string assemblyFile
, Evidence assemblySecurity
, string[] args
, byte[] hashValue
, AssemblyHashAlgorithm hashAlgorithm
)
630 Assembly a
= Assembly
.LoadFrom (assemblyFile
, assemblySecurity
, hashValue
, hashAlgorithm
);
631 return ExecuteAssemblyInternal (a
, args
);
636 public int ExecuteAssembly (string assemblyFile
, string[] args
)
638 Assembly a
= Assembly
.LoadFrom (assemblyFile
, null);
639 return ExecuteAssemblyInternal (a
, args
);
642 public int ExecuteAssembly (string assemblyFile
, string[] args
, byte[] hashValue
, AssemblyHashAlgorithm hashAlgorithm
)
644 Assembly a
= Assembly
.LoadFrom (assemblyFile
, null, hashValue
, hashAlgorithm
);
645 return ExecuteAssemblyInternal (a
, args
);
649 int ExecuteAssemblyInternal (Assembly a
, string[] args
)
651 if (a
.EntryPoint
== null)
652 throw new MissingMethodException ("Entry point not found in assembly '" + a
.FullName
+ "'.");
653 return ExecuteAssembly (a
, args
);
656 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
657 private extern int ExecuteAssembly (Assembly a
, string[] args
);
659 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
660 private extern Assembly
[] GetAssemblies (bool refOnly
);
662 public Assembly
[] GetAssemblies ()
664 return GetAssemblies (false);
667 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
668 public extern object GetData (string name
);
670 public new Type
GetType()
672 return base.GetType ();
675 public override object InitializeLifetimeService ()
680 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
681 internal extern Assembly
LoadAssembly (string assemblyRef
, Evidence securityEvidence
, bool refOnly
);
683 public Assembly
Load (AssemblyName assemblyRef
)
685 return Load (assemblyRef
, null);
688 internal Assembly
LoadSatellite (AssemblyName assemblyRef
, bool throwOnError
)
690 if (assemblyRef
== null)
691 throw new ArgumentNullException ("assemblyRef");
693 Assembly result
= LoadAssembly (assemblyRef
.FullName
, null, false);
694 if (result
== null && throwOnError
)
695 throw new FileNotFoundException (null, assemblyRef
.Name
);
700 [Obsolete ("Use an overload that does not take an Evidence parameter")]
702 public Assembly
Load (AssemblyName assemblyRef
, Evidence assemblySecurity
)
704 if (assemblyRef
== null)
705 throw new ArgumentNullException ("assemblyRef");
707 if (assemblyRef
.Name
== null || assemblyRef
.Name
.Length
== 0) {
708 if (assemblyRef
.CodeBase
!= null)
709 return Assembly
.LoadFrom (assemblyRef
.CodeBase
, assemblySecurity
);
711 throw new ArgumentException (Locale
.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
714 Assembly assembly
= LoadAssembly (assemblyRef
.FullName
, assemblySecurity
, false);
715 if (assembly
!= null)
718 if (assemblyRef
.CodeBase
== null)
719 throw new FileNotFoundException (null, assemblyRef
.Name
);
721 string cb
= assemblyRef
.CodeBase
;
722 if (cb
.ToLower (CultureInfo
.InvariantCulture
).StartsWith ("file://"))
723 cb
= new Mono
.Security
.Uri (cb
).LocalPath
;
726 assembly
= Assembly
.LoadFrom (cb
, assemblySecurity
);
728 throw new FileNotFoundException (null, assemblyRef
.Name
);
730 AssemblyName aname
= assembly
.GetName ();
731 // Name, version, culture, publickeytoken. Anything else?
732 if (assemblyRef
.Name
!= aname
.Name
)
733 throw new FileNotFoundException (null, assemblyRef
.Name
);
735 if (assemblyRef
.Version
!= new Version () && assemblyRef
.Version
!= aname
.Version
)
736 throw new FileNotFoundException (null, assemblyRef
.Name
);
738 if (assemblyRef
.CultureInfo
!= null && assemblyRef
.CultureInfo
.Equals (aname
))
739 throw new FileNotFoundException (null, assemblyRef
.Name
);
741 byte [] pt
= assemblyRef
.GetPublicKeyToken ();
743 byte [] loaded_pt
= aname
.GetPublicKeyToken ();
744 if (loaded_pt
== null || (pt
.Length
!= loaded_pt
.Length
))
745 throw new FileNotFoundException (null, assemblyRef
.Name
);
746 for (int i
= pt
.Length
- 1; i
>= 0; i
--)
747 if (loaded_pt
[i
] != pt
[i
])
748 throw new FileNotFoundException (null, assemblyRef
.Name
);
753 public Assembly
Load (string assemblyString
)
755 return Load (assemblyString
, null, false);
759 [Obsolete ("Use an overload that does not take an Evidence parameter")]
761 public Assembly
Load (string assemblyString
, Evidence assemblySecurity
)
763 return Load (assemblyString
, assemblySecurity
, false);
766 internal Assembly
Load (string assemblyString
, Evidence assemblySecurity
, bool refonly
)
768 if (assemblyString
== null)
769 throw new ArgumentNullException ("assemblyString");
771 if (assemblyString
.Length
== 0)
772 throw new ArgumentException ("assemblyString cannot have zero length");
774 Assembly assembly
= LoadAssembly (assemblyString
, assemblySecurity
, refonly
);
775 if (assembly
== null)
776 throw new FileNotFoundException (null, assemblyString
);
780 public Assembly
Load (byte[] rawAssembly
)
782 return Load (rawAssembly
, null, null);
785 public Assembly
Load (byte[] rawAssembly
, byte[] rawSymbolStore
)
787 return Load (rawAssembly
, rawSymbolStore
, null);
790 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
791 internal extern Assembly
LoadAssemblyRaw (byte[] rawAssembly
, byte[] rawSymbolStore
, Evidence securityEvidence
, bool refonly
);
794 [Obsolete ("Use an overload that does not take an Evidence parameter")]
796 public Assembly
Load (byte[] rawAssembly
, byte[] rawSymbolStore
, Evidence securityEvidence
)
798 return Load (rawAssembly
, rawSymbolStore
, securityEvidence
, false);
801 internal Assembly
Load (byte [] rawAssembly
, byte [] rawSymbolStore
, Evidence securityEvidence
, bool refonly
)
803 if (rawAssembly
== null)
804 throw new ArgumentNullException ("rawAssembly");
806 Assembly assembly
= LoadAssemblyRaw (rawAssembly
, rawSymbolStore
, securityEvidence
, refonly
);
807 assembly
.FromByteArray
= true;
812 [Obsolete ("AppDomain policy levels are obsolete")]
814 [SecurityPermission (SecurityAction
.Demand
, ControlPolicy
= true)]
815 public void SetAppDomainPolicy (PolicyLevel domainPolicy
)
817 if (domainPolicy
== null)
818 throw new ArgumentNullException ("domainPolicy");
819 if (_granted
!= null) {
820 throw new PolicyException (Locale
.GetText (
821 "An AppDomain policy is already specified."));
823 if (IsFinalizingForUnload ())
824 throw new AppDomainUnloadedException ();
826 PolicyStatement ps
= domainPolicy
.Resolve (_evidence
);
827 _granted
= ps
.PermissionSet
;
830 [Obsolete ("Use AppDomainSetup.SetCachePath")]
831 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
832 public void SetCachePath (string path
)
834 SetupInformationNoCopy
.CachePath
= path
;
837 [SecurityPermission (SecurityAction
.Demand
, ControlPrincipal
= true)]
838 public void SetPrincipalPolicy (PrincipalPolicy policy
)
840 if (IsFinalizingForUnload ())
841 throw new AppDomainUnloadedException ();
843 _principalPolicy
= policy
;
847 [Obsolete ("Use AppDomainSetup.ShadowCopyFiles")]
848 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
849 public void SetShadowCopyFiles()
851 SetupInformationNoCopy
.ShadowCopyFiles
= "true";
854 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
855 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
856 public void SetShadowCopyPath (string path
)
858 SetupInformationNoCopy
.ShadowCopyDirectories
= path
;
861 [SecurityPermission (SecurityAction
.Demand
, ControlPrincipal
= true)]
862 public void SetThreadPrincipal (IPrincipal principal
)
864 if (principal
== null)
865 throw new ArgumentNullException ("principal");
866 if (_principal
!= null)
867 throw new PolicyException (Locale
.GetText ("principal already present."));
868 if (IsFinalizingForUnload ())
869 throw new AppDomainUnloadedException ();
871 _principal
= principal
;
874 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
875 private static extern AppDomain
InternalSetDomainByID (int domain_id
);
877 // Changes the active domain and returns the old domain
878 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
879 private static extern AppDomain
InternalSetDomain (AppDomain context
);
881 // Notifies the runtime that this thread references 'domain'.
882 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
883 internal static extern void InternalPushDomainRef (AppDomain domain
);
885 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
886 internal static extern void InternalPushDomainRefByID (int domain_id
);
888 // Undoes the effect of the last PushDomainRef call
889 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
890 internal static extern void InternalPopDomainRef ();
892 // Changes the active context and returns the old context
893 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
894 internal static extern Context
InternalSetContext (Context context
);
896 // Returns the current context
897 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
898 internal static extern Context
InternalGetContext ();
900 // Returns the current context
901 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
902 internal static extern Context
InternalGetDefaultContext ();
904 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
905 internal static extern string InternalGetProcessGuid (string newguid
);
907 // This method is handled specially by the runtime
908 // It is the only managed method which is allowed to set the current
910 internal static object InvokeInDomain (AppDomain domain
, MethodInfo method
, object obj
, object [] args
)
912 AppDomain current
= CurrentDomain
;
917 InternalPushDomainRef (domain
);
919 InternalSetDomain (domain
);
920 object o
= ((MonoMethod
) method
).InternalInvoke (obj
, args
, out exc
);
926 InternalSetDomain (current
);
928 InternalPopDomainRef ();
932 internal static object InvokeInDomainByID (int domain_id
, MethodInfo method
, object obj
, object [] args
)
934 AppDomain current
= CurrentDomain
;
939 InternalPushDomainRefByID (domain_id
);
941 InternalSetDomainByID (domain_id
);
942 object o
= ((MonoMethod
) method
).InternalInvoke (obj
, args
, out exc
);
948 InternalSetDomain (current
);
950 InternalPopDomainRef ();
954 internal static String
GetProcessGuid ()
956 if (_process_guid
== null) {
957 _process_guid
= InternalGetProcessGuid (Guid
.NewGuid().ToString ());
959 return _process_guid
;
964 public static AppDomain
CreateDomain (string friendlyName
)
966 return CreateDomain (friendlyName
, null, null);
969 public static AppDomain
CreateDomain (string friendlyName
, Evidence securityInfo
)
971 return CreateDomain (friendlyName
, securityInfo
, null);
974 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
975 private static extern AppDomain
createDomain (string friendlyName
, AppDomainSetup info
);
977 [MonoLimitationAttribute ("Currently it does not allow the setup in the other domain")]
978 [SecurityPermission (SecurityAction
.Demand
, ControlAppDomain
= true)]
979 public static AppDomain
CreateDomain (string friendlyName
, Evidence securityInfo
, AppDomainSetup info
)
981 if (friendlyName
== null)
982 throw new System
.ArgumentNullException ("friendlyName");
984 AppDomain def
= AppDomain
.DefaultDomain
;
986 // if null, get default domain's SetupInformation
988 info
= new AppDomainSetup (); // we're default!
990 info
= def
.SetupInformation
;
993 info
= new AppDomainSetup (info
); // copy
995 // todo: allow setup in the other domain
997 if (!info
.Equals (def
.SetupInformation
)) {
998 // If not specified use default domain's app base.
999 if (info
.ApplicationBase
== null)
1000 info
.ApplicationBase
= def
.SetupInformation
.ApplicationBase
;
1001 if (info
.ConfigurationFile
== null)
1002 info
.ConfigurationFile
= Path
.GetFileName (def
.SetupInformation
.ConfigurationFile
);
1004 } else if (info
.ConfigurationFile
== null)
1005 info
.ConfigurationFile
= "[I don't have a config file]";
1008 if (info
.AppDomainInitializer
!= null) {
1009 if (!info
.AppDomainInitializer
.Method
.IsStatic
)
1010 throw new ArgumentException ("Non-static methods cannot be invoked as an appdomain initializer");
1014 info
.SerializeNonPrimitives ();
1016 AppDomain ad
= (AppDomain
) RemotingServices
.GetDomainProxy (createDomain (friendlyName
, info
));
1017 if (securityInfo
== null) {
1018 // get default domain's Evidence (unless we're are the default!)
1020 ad
._evidence
= null; // we'll get them later (GetEntryAssembly)
1022 ad
._evidence
= def
.Evidence
; // new (shallow) copy
1025 ad
._evidence
= new Evidence (securityInfo
); // copy
1028 if (info
.AppDomainInitializer
!= null) {
1029 Loader loader
= new Loader (
1030 info
.AppDomainInitializer
.Method
.DeclaringType
.Assembly
.Location
);
1031 ad
.DoCallBack (loader
.Load
);
1033 Initializer initializer
= new Initializer (
1034 info
.AppDomainInitializer
,
1035 info
.AppDomainInitializerArguments
);
1036 ad
.DoCallBack (initializer
.Initialize
);
1049 public Loader (string assembly
)
1051 this.assembly
= assembly
;
1056 Assembly
.LoadFrom (assembly
);
1063 AppDomainInitializer initializer
;
1064 string [] arguments
;
1066 public Initializer (AppDomainInitializer initializer
, string [] arguments
)
1068 this.initializer
= initializer
;
1069 this.arguments
= arguments
;
1072 public void Initialize ()
1074 initializer (arguments
);
1079 public static AppDomain
CreateDomain (string friendlyName
, Evidence securityInfo
,string appBasePath
,
1080 string appRelativeSearchPath
, bool shadowCopyFiles
)
1082 return CreateDomain (friendlyName
, securityInfo
, CreateDomainSetup (appBasePath
, appRelativeSearchPath
, shadowCopyFiles
));
1086 public static AppDomain
CreateDomain (string friendlyName
, Evidence securityInfo
, AppDomainSetup info
,
1087 PermissionSet grantSet
, params StrongName
[] fullTrustAssemblies
)
1090 throw new ArgumentNullException ("info");
1092 info
.ApplicationTrust
= new ApplicationTrust (grantSet
, fullTrustAssemblies
?? new StrongName
[0]);
1093 return CreateDomain (friendlyName
, securityInfo
, info
);
1097 static AppDomainSetup
CreateDomainSetup (string appBasePath
, string appRelativeSearchPath
, bool shadowCopyFiles
)
1099 AppDomainSetup info
= new AppDomainSetup ();
1101 info
.ApplicationBase
= appBasePath
;
1102 info
.PrivateBinPath
= appRelativeSearchPath
;
1104 if (shadowCopyFiles
)
1105 info
.ShadowCopyFiles
= "true";
1107 info
.ShadowCopyFiles
= "false";
1113 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
1114 private static extern bool InternalIsFinalizingForUnload (int domain_id
);
1116 public bool IsFinalizingForUnload()
1118 return InternalIsFinalizingForUnload (getDomainID ());
1121 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
1122 static extern void InternalUnload (int domain_id
);
1124 // We do this because if the domain is a transparant proxy this
1125 // will still return the correct domain id.
1126 private int getDomainID ()
1128 return Thread
.GetDomainID ();
1131 [SecurityPermission (SecurityAction
.Demand
, ControlAppDomain
= true)]
1132 [ReliabilityContractAttribute (Consistency
.MayCorruptAppDomain
, Cer
.MayFail
)]
1133 public static void Unload (AppDomain domain
)
1136 throw new ArgumentNullException ("domain");
1138 InternalUnload (domain
.getDomainID());
1141 [MethodImplAttribute (MethodImplOptions
.InternalCall
)]
1142 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1143 public extern void SetData (string name
, object data
);
1145 [MonoLimitation ("The permission field is ignored")]
1146 public void SetData (string name
, object data
, IPermission permission
)
1148 SetData (name
, data
);
1152 [Obsolete ("Use AppDomainSetup.DynamicBase")]
1153 [SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1154 public void SetDynamicBase (string path
)
1156 SetupInformationNoCopy
.DynamicBase
= path
;
1160 [Obsolete ("AppDomain.GetCurrentThreadId has been deprecated"
1161 + " because it does not provide a stable Id when managed"
1162 + " threads are running on fibers (aka lightweight"
1163 + " threads). To get a stable identifier for a managed"
1164 + " thread, use the ManagedThreadId property on Thread.'")]
1165 public static int GetCurrentThreadId ()
1167 return Thread
.CurrentThreadId
;
1170 public override string ToString ()
1173 return getFriendlyName ();
1175 StringBuilder sb
= new StringBuilder ("Name:");
1176 sb
.AppendLine (FriendlyName
);
1177 sb
.AppendLine ("There are no context policies.");
1178 return sb
.ToString ();
1182 private static void ValidateAssemblyName (string name
)
1184 if (name
== null || name
.Length
== 0)
1185 throw new ArgumentException ("The Name of " +
1186 "AssemblyName cannot be null or a " +
1187 "zero-length string.");
1189 bool isValid
= true;
1191 for (int i
= 0; i
< name
.Length
; i
++) {
1194 // do not allow leading whitespace
1195 if (i
== 0 && char.IsWhiteSpace (c
)) {
1200 // do not allow /,\ or : in name
1201 if (c
== '/' || c
== '\\' || c
== ':') {
1208 throw new ArgumentException ("The Name of " +
1209 "AssemblyName cannot start with " +
1210 "whitespace, or contain '/', '\\' " +
1214 // The following methods are called from the runtime. Don't change signatures.
1215 #pragma warning disable 169
1216 private void DoAssemblyLoad (Assembly assembly
)
1218 if (AssemblyLoad
== null)
1221 AssemblyLoad (this, new AssemblyLoadEventArgs (assembly
));
1224 private Assembly
DoAssemblyResolve (string name
, bool refonly
)
1226 ResolveEventHandler del
;
1229 del
= ReflectionOnlyAssemblyResolve
;
1231 del
= AssemblyResolve
;
1233 del
= AssemblyResolve
;
1238 /* Prevent infinite recursion */
1241 ht
= assembly_resolve_in_progress_refonly
;
1243 ht
= new Hashtable ();
1244 assembly_resolve_in_progress_refonly
= ht
;
1247 ht
= assembly_resolve_in_progress
;
1249 ht
= new Hashtable ();
1250 assembly_resolve_in_progress
= ht
;
1254 string s
= (string) ht
[name
];
1259 Delegate
[] invocation_list
= del
.GetInvocationList ();
1261 foreach (Delegate eh
in invocation_list
) {
1262 ResolveEventHandler handler
= (ResolveEventHandler
) eh
;
1263 Assembly assembly
= handler (this, new ResolveEventArgs (name
));
1264 if (assembly
!= null)
1274 internal Assembly
DoTypeResolve (Object name_or_tb
)
1276 if (TypeResolve
== null)
1281 if (name_or_tb
is TypeBuilder
)
1282 name
= ((TypeBuilder
) name_or_tb
).FullName
;
1284 name
= (string) name_or_tb
;
1286 /* Prevent infinite recursion */
1287 Hashtable ht
= type_resolve_in_progress
;
1289 ht
= new Hashtable ();
1290 type_resolve_in_progress
= ht
;
1293 if (ht
.Contains (name
))
1299 foreach (Delegate d
in TypeResolve
.GetInvocationList ()) {
1300 ResolveEventHandler eh
= (ResolveEventHandler
) d
;
1301 Assembly assembly
= eh (this, new ResolveEventArgs (name
));
1302 if (assembly
!= null)
1312 private void DoDomainUnload ()
1314 if (DomainUnload
!= null)
1315 DomainUnload(this, null);
1319 internal byte[] GetMarshalledDomainObjRef ()
1321 ObjRef oref
= RemotingServices
.Marshal (AppDomain
.CurrentDomain
, null, typeof (AppDomain
));
1322 return CADSerializer
.SerializeObject (oref
).GetBuffer();
1325 internal void ProcessMessageInDomain (byte[] arrRequest
, CADMethodCallMessage cadMsg
,
1326 out byte[] arrResponse
, out CADMethodReturnMessage cadMrm
)
1330 if (null != arrRequest
)
1331 reqDomMsg
= CADSerializer
.DeserializeMessage (new MemoryStream(arrRequest
), null);
1333 reqDomMsg
= new MethodCall (cadMsg
);
1335 IMessage retDomMsg
= ChannelServices
.SyncDispatchMessage (reqDomMsg
);
1337 cadMrm
= CADMethodReturnMessage
.Create (retDomMsg
);
1338 if (null == cadMrm
) {
1339 arrResponse
= CADSerializer
.SerializeMessage (retDomMsg
).GetBuffer();
1345 #pragma warning restore 169
1347 // End of methods called from the runtime
1349 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1350 public event AssemblyLoadEventHandler AssemblyLoad
;
1352 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1353 public event ResolveEventHandler AssemblyResolve
;
1355 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1356 public event EventHandler DomainUnload
;
1358 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1359 public event EventHandler ProcessExit
;
1361 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1362 public event ResolveEventHandler ResourceResolve
;
1364 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1365 public event ResolveEventHandler TypeResolve
;
1367 [method
: SecurityPermission (SecurityAction
.LinkDemand
, ControlAppDomain
= true)]
1368 public event UnhandledExceptionEventHandler UnhandledException
;
1370 #if NET_4_0 || BOOTSTRAP_NET_4_0
1372 public bool IsHomogenous
{
1373 get { return true; }
1377 #pragma warning disable 649
1378 private AppDomainManager _domain_manager
;
1379 #pragma warning restore 649
1382 public AppDomainManager DomainManager
{
1383 get { return _domain_manager; }
1388 public event ResolveEventHandler ReflectionOnlyAssemblyResolve
;
1390 #pragma warning disable 649
1391 private ActivationContext _activation
;
1392 private ApplicationIdentity _applicationIdentity
;
1393 #pragma warning restore 649
1397 public ActivationContext ActivationContext
{
1398 get { return _activation; }
1401 public ApplicationIdentity ApplicationIdentity
{
1402 get { return _applicationIdentity; }
1406 [ReliabilityContract (Consistency
.WillNotCorruptState
, Cer
.Success
)]
1407 get { return getDomainID (); }
1412 [MonoTODO ("This routine only returns the parameter currently")]
1413 [ComVisible (false)]
1414 public string ApplyPolicy (string assemblyName
)
1416 if (assemblyName
== null)
1417 throw new ArgumentNullException ("assemblyName");
1418 if (assemblyName
.Length
== 0) // String.Empty
1419 throw new ArgumentException ("assemblyName");
1420 return assemblyName
;
1425 public static AppDomain
CreateDomain (string friendlyName
, Evidence securityInfo
, string appBasePath
,
1426 string appRelativeSearchPath
, bool shadowCopyFiles
, AppDomainInitializer adInit
, string[] adInitArgs
)
1428 AppDomainSetup info
= CreateDomainSetup (appBasePath
, appRelativeSearchPath
, shadowCopyFiles
);
1430 info
.AppDomainInitializerArguments
= adInitArgs
;
1431 info
.AppDomainInitializer
= adInit
;
1433 return CreateDomain (friendlyName
, securityInfo
, info
);
1436 public int ExecuteAssemblyByName (string assemblyName
)
1438 return ExecuteAssemblyByName (assemblyName
, (Evidence
)null, null);
1442 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1444 public int ExecuteAssemblyByName (string assemblyName
, Evidence assemblySecurity
)
1446 return ExecuteAssemblyByName (assemblyName
, assemblySecurity
, null);
1450 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1452 public int ExecuteAssemblyByName (string assemblyName
, Evidence assemblySecurity
, params string[] args
)
1454 Assembly a
= Assembly
.Load (assemblyName
, assemblySecurity
);
1456 return ExecuteAssemblyInternal (a
, args
);
1460 [Obsolete ("Use an overload that does not take an Evidence parameter")]
1462 public int ExecuteAssemblyByName (AssemblyName assemblyName
, Evidence assemblySecurity
, params string[] args
)
1464 Assembly a
= Assembly
.Load (assemblyName
, assemblySecurity
);
1466 return ExecuteAssemblyInternal (a
, args
);
1470 public int ExecuteAssemblyByName (string assemblyName
, params string[] args
)
1472 Assembly a
= Assembly
.Load (assemblyName
, null);
1474 return ExecuteAssemblyInternal (a
, args
);
1477 public int ExecuteAssemblyByName (AssemblyName assemblyName
, params string[] args
)
1479 Assembly a
= Assembly
.Load (assemblyName
, null);
1481 return ExecuteAssemblyInternal (a
, args
);
1485 public bool IsDefaultAppDomain ()
1487 return Object
.ReferenceEquals (this, DefaultDomain
);
1490 public Assembly
[] ReflectionOnlyGetAssemblies ()
1492 return GetAssemblies (true);
1497 public int ExecuteAssemblyByName (string assemblyName
)
1499 // critical code in SL that we're not calling in ML
1500 throw new NotImplementedException ();
1505 void _AppDomain
.GetIDsOfNames ([In
] ref Guid riid
, IntPtr rgszNames
, uint cNames
, uint lcid
, IntPtr rgDispId
)
1507 throw new NotImplementedException ();
1510 void _AppDomain
.GetTypeInfo (uint iTInfo
, uint lcid
, IntPtr ppTInfo
)
1512 throw new NotImplementedException ();
1515 void _AppDomain
.GetTypeInfoCount (out uint pcTInfo
)
1517 throw new NotImplementedException ();
1520 void _AppDomain
.Invoke (uint dispIdMember
, [In
] ref Guid riid
, uint lcid
, short wFlags
, IntPtr pDispParams
,
1521 IntPtr pVarResult
, IntPtr pExcepInfo
, IntPtr puArgErr
)
1523 throw new NotImplementedException ();
1527 #if NET_4_0 || MOONLIGHT
1528 [MonoTODO ("Currently always returns false")]
1529 public bool? IsCompatibilitySwitchSet (string value)
1532 throw new ArgumentNullException ("value");
1533 // default (at least for SL4) is to return false for unknown values (can't get a null out of it)
1537 [MonoTODO ("Currently always returns false")]
1538 public static bool MonitoringIsEnabled
{
1539 get { return false; }
1540 set { throw new NotImplementedException (); }
1544 public long MonitoringSurvivedMemorySize
{
1545 get { throw new NotImplementedException (); }
1549 public static long MonitoringSurvivedProcessMemorySize
{
1550 get { throw new NotImplementedException (); }
1554 public long MonitoringTotalAllocatedMemorySize
{
1555 get { throw new NotImplementedException (); }
1559 public TimeSpan MonitoringTotalProcessorTime
{
1560 get { throw new NotImplementedException (); }