2008-08-26 Robert Jordan <robertj@gmx.net>
[mono.git] / mcs / class / corlib / System / AppDomain.cs
1 //
2 // System.AppDomain.cs
3 //
4 // Authors:
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)
9 //   Patrik Torstensson
10 //   Sebastien Pouliot (sebastien@ximian.com)
11 //
12 // (C) 2001, 2002 Ximian, Inc.  http://www.ximian.com
13 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
14 //
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:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
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.
33 //
34
35 using System.Collections;
36 using System.Globalization;
37 using System.IO;
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;
52
53 #if NET_2_0
54 using System.Collections.Generic;
55 using System.Runtime.ConstrainedExecution;
56 #endif
57
58 namespace System {
59
60 #if NET_2_0
61         [ComVisible (true)]
62         [ComDefaultInterface (typeof (_AppDomain))]
63 #endif
64         [ClassInterface(ClassInterfaceType.None)]
65         public sealed class AppDomain : MarshalByRefObject , _AppDomain , IEvidenceFactory
66         {
67                 IntPtr _mono_app_domain;
68                 static string _process_guid;
69
70                 [ThreadStatic]
71                 static Hashtable type_resolve_in_progress;
72
73                 [ThreadStatic]
74                 static Hashtable assembly_resolve_in_progress;
75
76                 // CAS
77                 private Evidence _evidence;
78                 private PermissionSet _granted;
79
80                 // non-CAS
81                 private PrincipalPolicy _principalPolicy;
82
83                 [ThreadStatic]
84                 private static IPrincipal _principal;
85                 
86                 static AppDomain default_domain;
87
88                 private AppDomain ()
89                 {
90                 }
91
92                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
93                 private extern AppDomainSetup getSetup ();
94
95                 AppDomainSetup SetupInformationNoCopy {
96                         get { return getSetup (); }
97                 }
98
99                 public AppDomainSetup SetupInformation {
100                         get {
101                                 AppDomainSetup setup = getSetup ();
102                                 return new AppDomainSetup (setup);
103                         }
104                 }
105
106 #if NET_2_0
107                 [MonoTODO]
108                 public ApplicationTrust ApplicationTrust {
109                         get { throw new NotImplementedException (); }
110                 }
111 #endif
112
113                 public string BaseDirectory {
114                         get {
115                                 string path = SetupInformationNoCopy.ApplicationBase;
116                                 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
117                                         // we cannot divulge local file informations
118                                         new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
119                                 }
120                                 return path;
121                         }
122                 }
123
124                 public string RelativeSearchPath {
125                         get {
126                                 string path = SetupInformationNoCopy.PrivateBinPath;
127                                 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
128                                         // we cannot divulge local file informations
129                                         new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
130                                 }
131                                 return path;
132                         }
133                 }
134
135                 public string DynamicDirectory {
136                         get {
137                                 AppDomainSetup setup = SetupInformationNoCopy;
138                                 if (setup.DynamicBase == null)
139                                         return null;
140
141                                 string path = Path.Combine (setup.DynamicBase, setup.ApplicationName);
142                                 if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
143                                         // we cannot divulge local file informations
144                                         new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
145                                 }
146                                 return path;
147                         }
148                 }
149
150                 public bool ShadowCopyFiles {
151                         get {
152                                 return (SetupInformationNoCopy.ShadowCopyFiles == "true");
153                         }
154                 }
155
156                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
157                 private extern string getFriendlyName ();
158
159                 public string FriendlyName {
160                         get {
161                                 return getFriendlyName ();
162                         }
163                 }
164
165                 public Evidence Evidence {
166                         get {
167                                 // if the host (runtime) hasn't provided it's own evidence...
168                                 if (_evidence == null) {
169                                         // ... we will provide our own
170                                         lock (this) {
171                                                 // the executed assembly from the "default" appdomain
172                                                 // or null if we're not in the default appdomain or
173                                                 // if there is no entry assembly (embedded mono)
174                                                 Assembly a = Assembly.GetEntryAssembly ();
175                                                 if (a == null) {
176                                                         if (this == DefaultDomain)
177                                                                 // mono is embedded
178                                                                 return new Evidence ();
179                                                         else
180                                                                 _evidence = AppDomain.DefaultDomain.Evidence;
181                                                 } else {
182                                                         _evidence = Evidence.GetDefaultHostEvidence (a);
183                                                 }
184                                         }
185                                 }
186                                 return new Evidence (_evidence);        // return a copy
187                         }
188                 }
189
190                 internal IPrincipal DefaultPrincipal {
191                         get {
192                                 if (_principal == null) {
193                                         switch (_principalPolicy) {
194                                                 case PrincipalPolicy.UnauthenticatedPrincipal:
195                                                         _principal = new GenericPrincipal (
196                                                                 new GenericIdentity (String.Empty, String.Empty), null);
197                                                         break;
198                                                 case PrincipalPolicy.WindowsPrincipal:
199                                                         _principal = new WindowsPrincipal (WindowsIdentity.GetCurrent ());
200                                                         break;
201                                         }
202                                 }
203                                 return _principal; 
204                         }
205                 }
206
207                 // for AppDomain there is only an allowed (i.e. granted) set
208                 // http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondetermininggrantedpermissions.asp
209                 internal PermissionSet GrantedPermissionSet {
210                         get { return _granted; }
211                 }
212
213                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
214                 private static extern AppDomain getCurDomain ();
215                 
216                 public static AppDomain CurrentDomain {
217                         get {
218                                 return getCurDomain ();
219                         }
220                 }
221
222                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
223                 private static extern AppDomain getRootDomain ();
224
225                 internal static AppDomain DefaultDomain {
226                         get {
227                                 if (default_domain == null) {
228                                         AppDomain rd = getRootDomain ();
229                                         if (rd == CurrentDomain)
230                                                 default_domain = rd;
231                                         else
232                                                 default_domain = (AppDomain) RemotingServices.GetDomainProxy (rd);
233                                 }
234                                 return default_domain;
235                         }
236                 }
237
238 #if NET_2_0
239                 [Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
240 #endif
241                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
242                 public void AppendPrivatePath (string path)
243                 {
244                         if (path == null || path.Length == 0)
245                                 return;
246
247                         AppDomainSetup setup = SetupInformationNoCopy;
248
249                         string pp = setup.PrivateBinPath;
250                         if (pp == null || pp.Length == 0) {
251                                 setup.PrivateBinPath = path;
252                                 return;
253                         }
254
255                         pp = pp.Trim ();
256                         if (pp [pp.Length - 1] != Path.PathSeparator)
257                                 pp += Path.PathSeparator;
258
259                         setup.PrivateBinPath = pp + path;
260                 }
261
262 #if NET_2_0
263                 [Obsolete ("AppDomain.ClearPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
264 #endif
265                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
266                 public void ClearPrivatePath ()
267                 {
268                         SetupInformationNoCopy.PrivateBinPath = String.Empty;
269                 }
270
271 #if NET_2_0
272                 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
273 #endif
274                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
275                 public void ClearShadowCopyPath ()
276                 {
277                         SetupInformationNoCopy.ShadowCopyDirectories = String.Empty;
278                 }
279
280                 public ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
281                 {
282                         return Activator.CreateComInstanceFrom (assemblyName, typeName);
283                 }
284
285 #if NET_1_1
286                 public ObjectHandle CreateComInstanceFrom (string assemblyFile, string typeName,
287                         byte [] hashValue, AssemblyHashAlgorithm hashAlgorithm)
288                 {
289                         return Activator.CreateComInstanceFrom (assemblyFile, typeName, hashValue ,hashAlgorithm);
290                 }
291 #endif
292
293                 public ObjectHandle CreateInstance (string assemblyName, string typeName)
294                 {
295                         if (assemblyName == null)
296                                 throw new ArgumentNullException ("assemblyName");
297
298                         return Activator.CreateInstance (assemblyName, typeName);
299                 }
300
301                 public ObjectHandle CreateInstance (string assemblyName, string typeName, object[] activationAttributes)
302                 {
303                         if (assemblyName == null)
304                                 throw new ArgumentNullException ("assemblyName");
305
306                         return Activator.CreateInstance (assemblyName, typeName, activationAttributes);
307                 }
308
309                 public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
310                                                     Binder binder, object[] args, CultureInfo culture, object[] activationAttributes,
311                                                     Evidence securityAttributes)
312                 {
313                         if (assemblyName == null)
314                                 throw new ArgumentNullException ("assemblyName");
315
316                         return Activator.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
317                                 culture, activationAttributes, securityAttributes);
318                 }
319
320                 public object CreateInstanceAndUnwrap (string assemblyName, string typeName)
321                 {
322                         ObjectHandle oh = CreateInstance (assemblyName, typeName);
323                         return (oh != null) ? oh.Unwrap () : null;
324                 }
325
326                 public object CreateInstanceAndUnwrap (string assemblyName, string typeName, object [] activationAttributes)
327                 {
328                         ObjectHandle oh = CreateInstance (assemblyName, typeName, activationAttributes);
329                         return (oh != null) ? oh.Unwrap () : null;
330                 }
331
332                 public object CreateInstanceAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
333                                                        BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
334                                                        object[] activationAttributes, Evidence securityAttributes)
335                 {
336                         ObjectHandle oh = CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
337                                 culture, activationAttributes, securityAttributes);
338                         return (oh != null) ? oh.Unwrap () : null;
339                 }
340
341                 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
342                 {
343                         if (assemblyFile == null)
344                                 throw new ArgumentNullException ("assemblyFile");
345
346                         return Activator.CreateInstanceFrom (assemblyFile, typeName);
347                 }
348
349                 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, object[] activationAttributes)
350                 {
351                         if (assemblyFile == null)
352                                 throw new ArgumentNullException ("assemblyFile");
353
354                         return Activator.CreateInstanceFrom (assemblyFile, typeName, activationAttributes);
355                 }
356
357                 public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
358                                                         BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
359                                                         object[] activationAttributes, Evidence securityAttributes)
360                 {
361                         if (assemblyFile == null)
362                                 throw new ArgumentNullException ("assemblyFile");
363
364                         return Activator.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args,
365                                                              culture, activationAttributes, securityAttributes);
366                 }
367
368                 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName)
369                 {
370                         ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName);
371                         return (oh != null) ? oh.Unwrap () : null;
372                 }
373
374                 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, object [] activationAttributes)
375                 {
376                         ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, activationAttributes);
377                         return (oh != null) ? oh.Unwrap () : null;
378                 }
379
380                 public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
381                                                            BindingFlags bindingAttr, Binder binder, object[] args,
382                                                            CultureInfo culture, object[] activationAttributes,
383                                                            Evidence securityAttributes)
384                 {
385                         ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
386                                 culture, activationAttributes, securityAttributes);
387
388                         return (oh != null) ? oh.Unwrap () : null;
389                 }
390
391                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
392                 {
393                         return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
394                 }
395
396                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence)
397                 {
398                         return DefineDynamicAssembly (name, access, null, evidence, null, null, null, false);
399                 }
400
401                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir)
402                 {
403                         return DefineDynamicAssembly (name, access, dir, null, null, null, null, false);
404                 }
405
406                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
407                                                               Evidence evidence)
408                 {
409                         return DefineDynamicAssembly (name, access, dir, evidence, null, null, null, false);
410                 }
411
412                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
413                                                               PermissionSet requiredPermissions,
414                                                               PermissionSet optionalPermissions,
415                                                               PermissionSet refusedPermissions)
416                 {
417                         return DefineDynamicAssembly (name, access, null, null, requiredPermissions, optionalPermissions,
418                                 refusedPermissions, false);
419                 }
420
421                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence,
422                                                               PermissionSet requiredPermissions,
423                                                               PermissionSet optionalPermissions,
424                                                               PermissionSet refusedPermissions)
425                 {
426                         return DefineDynamicAssembly (name, access, null, evidence, requiredPermissions, optionalPermissions,
427                                 refusedPermissions, false);
428                 }
429
430                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
431                                                               PermissionSet requiredPermissions,
432                                                               PermissionSet optionalPermissions,
433                                                               PermissionSet refusedPermissions)
434                 {
435                         return DefineDynamicAssembly (name, access, dir, null, requiredPermissions, optionalPermissions,
436                                 refusedPermissions, false);
437                 }
438
439                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
440                                                               Evidence evidence,
441                                                               PermissionSet requiredPermissions,
442                                                               PermissionSet optionalPermissions,
443                                                               PermissionSet refusedPermissions)
444                 {
445                         return DefineDynamicAssembly (name, access, dir, evidence, requiredPermissions, optionalPermissions,
446                                 refusedPermissions, false);
447                 }
448
449                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
450                                                               Evidence evidence,
451                                                               PermissionSet requiredPermissions,
452                                                               PermissionSet optionalPermissions,
453                                                               PermissionSet refusedPermissions, bool isSynchronized)
454                 {
455                         if (name == null)
456                                 throw new ArgumentNullException ("name");
457                         ValidateAssemblyName (name.Name);
458
459                         // FIXME: examine all other parameters
460                         
461                         AssemblyBuilder ab = new AssemblyBuilder (name, dir, access, false);
462                         ab.AddPermissionRequests (requiredPermissions, optionalPermissions, refusedPermissions);
463                         return ab;
464                 }
465
466 #if NET_2_0
467                 // NET 3.5 method
468                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
469                                                               Evidence evidence,
470                                                               PermissionSet requiredPermissions,
471                                                               PermissionSet optionalPermissions,
472                                                               PermissionSet refusedPermissions, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
473                 {
474                         AssemblyBuilder ab = DefineDynamicAssembly (name, access, dir, evidence, requiredPermissions, optionalPermissions, refusedPermissions, isSynchronized);
475                         if (assemblyAttributes != null)
476                                 foreach (CustomAttributeBuilder cb in assemblyAttributes) {
477                                         ab.SetCustomAttribute (cb);
478                                 }
479                         return ab;
480                 }
481
482                 // NET 3.5 method
483                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes) {
484                         return DefineDynamicAssembly (name, access, null, null, null, null, null, false, assemblyAttributes);
485                 }
486 #endif
487
488 #if NET_2_1
489                 // TODO: the last parameter is ignored for now
490                 public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, bool emitSymbolInfo)
491                 {
492                         return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
493                 }
494 #endif
495
496                 internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
497                 {
498                         return new AssemblyBuilder (name, null, access, true);
499                 }
500
501                 //
502                 // AppDomain.DoCallBack works because AppDomain is a MarshalByRefObject
503                 // so, when you call AppDomain.DoCallBack, that's a remote call
504                 //
505                 public void DoCallBack (CrossAppDomainDelegate callBackDelegate)
506                 {
507                         if (callBackDelegate != null)
508                                 callBackDelegate ();
509                 }
510
511                 public int ExecuteAssembly (string assemblyFile)
512                 {
513                         return ExecuteAssembly (assemblyFile, null, null);
514                 }
515
516                 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity)
517                 {
518                         return ExecuteAssembly (assemblyFile, assemblySecurity, null);
519                 }
520
521                 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args)
522                 {
523                         Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity);
524                         return ExecuteAssemblyInternal (a, args);
525                 }
526
527                 public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
528                 {
529                         Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity, hashValue, hashAlgorithm);
530                         return ExecuteAssemblyInternal (a, args);
531                 }
532
533                 int ExecuteAssemblyInternal (Assembly a, string[] args)
534                 {
535                         if (a.EntryPoint == null)
536 #if NET_2_0
537                                 throw new MissingMethodException ("Entry point not found in assembly '" + a.FullName + "'.");
538 #else
539                                 throw new COMException ("Unspecified error.", -2147467259);
540 #endif
541                         return ExecuteAssembly (a, args);
542                 }
543
544                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
545                 private extern int ExecuteAssembly (Assembly a, string[] args);
546                 
547                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
548                 private extern Assembly [] GetAssemblies (bool refOnly);
549
550                 public Assembly [] GetAssemblies ()
551                 {
552                         return GetAssemblies (false);
553                 }
554
555                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
556                 public extern object GetData (string name);
557
558                 public new Type GetType()
559                 {
560                         return base.GetType ();
561                 }
562
563                 public override object InitializeLifetimeService ()
564                 {
565                         return null;
566                 }
567
568                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
569                 internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly);
570
571                 public Assembly Load (AssemblyName assemblyRef)
572                 {
573                         return Load (assemblyRef, null);
574                 }
575
576                 public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
577                 {
578                         if (assemblyRef == null)
579                                 throw new ArgumentNullException ("assemblyRef");
580
581                         if (assemblyRef.Name == null || assemblyRef.Name.Length == 0) {
582                                 if (assemblyRef.CodeBase != null)
583                                         return Assembly.LoadFrom (assemblyRef.CodeBase, assemblySecurity);
584                                 else
585                                         throw new ArgumentException (Locale.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
586                         }
587
588                         return LoadAssembly (assemblyRef.FullName, assemblySecurity, false);
589                 }
590
591                 public Assembly Load (string assemblyString)
592                 {
593                         return Load (assemblyString, null, false);
594                 }
595
596                 public Assembly Load (string assemblyString, Evidence assemblySecurity)
597                 {
598                         return Load (assemblyString, assemblySecurity, false);
599                 }
600                 
601                 internal Assembly Load (string assemblyString, Evidence assemblySecurity, bool refonly)
602                 {
603                         if (assemblyString == null)
604                                 throw new ArgumentNullException ("assemblyString");
605                                 
606                         if (assemblyString.Length == 0)
607                                 throw new ArgumentException ("assemblyString cannot have zero length");
608
609                         return LoadAssembly (assemblyString, assemblySecurity, refonly);
610                 }
611
612                 public Assembly Load (byte[] rawAssembly)
613                 {
614                         return Load (rawAssembly, null, null);
615                 }
616
617                 public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore)
618                 {
619                         return Load (rawAssembly, rawSymbolStore, null);
620                 }
621
622                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
623                 internal extern Assembly LoadAssemblyRaw (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence, bool refonly);
624
625                 public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
626                 {
627                         return Load (rawAssembly, rawSymbolStore, securityEvidence, false);
628                 }
629
630                 internal Assembly Load (byte [] rawAssembly, byte [] rawSymbolStore, Evidence securityEvidence, bool refonly)
631                 {
632                         if (rawAssembly == null)
633                                 throw new ArgumentNullException ("rawAssembly");
634
635                         Assembly assembly = LoadAssemblyRaw (rawAssembly, rawSymbolStore, securityEvidence, refonly);
636                         assembly.FromByteArray = true;
637                         return assembly;
638                 }
639
640                 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
641                 public void SetAppDomainPolicy (PolicyLevel domainPolicy)
642                 {
643                         if (domainPolicy == null)
644                                 throw new ArgumentNullException ("domainPolicy");
645                         if (_granted != null) {
646                                 throw new PolicyException (Locale.GetText (
647                                         "An AppDomain policy is already specified."));
648                         }
649                         if (IsFinalizingForUnload ())
650                                 throw new AppDomainUnloadedException ();
651
652                         PolicyStatement ps = domainPolicy.Resolve (_evidence);
653                         _granted = ps.PermissionSet;
654                 }
655
656 #if NET_2_0
657                 [Obsolete ("Use AppDomainSetup.SetCachePath")]
658 #endif
659                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
660                 public void SetCachePath (string path)
661                 {
662                         SetupInformationNoCopy.CachePath = path;
663                 }
664
665                 [SecurityPermission (SecurityAction.Demand, ControlPrincipal = true)]
666                 public void SetPrincipalPolicy (PrincipalPolicy policy)
667                 {
668                         if (IsFinalizingForUnload ())
669                                 throw new AppDomainUnloadedException ();
670
671                         _principalPolicy = policy;
672                         _principal = null;
673                 }
674
675 #if NET_2_0
676                 [Obsolete ("Use AppDomainSetup.ShadowCopyFiles")]
677 #endif
678                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
679                 public void SetShadowCopyFiles()
680                 {
681                         SetupInformationNoCopy.ShadowCopyFiles = "true";
682                 }
683
684 #if NET_2_0
685                 [Obsolete ("Use AppDomainSetup.ShadowCopyDirectories")]
686 #endif
687                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
688                 public void SetShadowCopyPath (string path)
689                 {
690                         SetupInformationNoCopy.ShadowCopyDirectories = path;
691                 }
692
693                 [SecurityPermission (SecurityAction.Demand, ControlPrincipal = true)]
694                 public void SetThreadPrincipal (IPrincipal principal)
695                 {
696                         if (principal == null)
697                                 throw new ArgumentNullException ("principal");
698                         if (_principal != null)
699                                 throw new PolicyException (Locale.GetText ("principal already present."));
700                         if (IsFinalizingForUnload ())
701                                 throw new AppDomainUnloadedException ();
702
703                         _principal = principal;
704                 }
705
706                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
707                 private static extern AppDomain InternalSetDomainByID (int domain_id);
708  
709                 // Changes the active domain and returns the old domain
710                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
711                 private static extern AppDomain InternalSetDomain (AppDomain context);
712
713                 // Notifies the runtime that this thread references 'domain'.
714                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
715                 internal static extern void InternalPushDomainRef (AppDomain domain);
716
717                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
718                 internal static extern void InternalPushDomainRefByID (int domain_id);
719
720                 // Undoes the effect of the last PushDomainRef call
721                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
722                 internal static extern void InternalPopDomainRef ();
723
724                 // Changes the active context and returns the old context
725                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
726                 internal static extern Context InternalSetContext (Context context);
727
728                 // Returns the current context
729                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
730                 internal static extern Context InternalGetContext ();
731
732                 // Returns the current context
733                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
734                 internal static extern Context InternalGetDefaultContext ();
735
736                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
737                 internal static extern string InternalGetProcessGuid (string newguid);
738
739                 // This method is handled specially by the runtime
740                 // It is the only managed method which is allowed to set the current
741                 // appdomain
742                 internal static object InvokeInDomain (AppDomain domain, MethodInfo method, object obj, object [] args)
743                 {
744                         AppDomain current = CurrentDomain;
745                         bool pushed = false;
746
747                         try {
748                                 Exception exc;
749                                 InternalPushDomainRef (domain);
750                                 pushed = true;
751                                 InternalSetDomain (domain);
752                                 object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
753                                 if (exc != null)
754                                         throw exc;
755                                 return o;
756                         }
757                         finally {
758                                 InternalSetDomain (current);
759                                 if (pushed)
760                                         InternalPopDomainRef ();
761                         }
762                 }
763
764                 internal static object InvokeInDomainByID (int domain_id, MethodInfo method, object obj, object [] args)
765                 {
766                         AppDomain current = CurrentDomain;
767                         bool pushed = false;
768
769                         try {
770                                 Exception exc;
771                                 InternalPushDomainRefByID (domain_id);
772                                 pushed = true;
773                                 InternalSetDomainByID (domain_id);
774                                 object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
775                                 if (exc != null)
776                                         throw exc;
777                                 return o;
778                         }
779                         finally {
780                                 InternalSetDomain (current);
781                                 if (pushed)
782                                         InternalPopDomainRef ();
783                         }
784                 }
785
786                 internal static String GetProcessGuid ()
787                 {
788                         if (_process_guid == null) {
789                                 _process_guid = InternalGetProcessGuid (Guid.NewGuid().ToString ());
790                         }
791                         return _process_guid;
792                 }
793
794                 public static AppDomain CreateDomain (string friendlyName)
795                 {
796                         return CreateDomain (friendlyName, null, null);
797                 }
798                 
799                 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo)
800                 {
801                         return CreateDomain (friendlyName, securityInfo, null);
802                 }
803
804                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
805                 private static extern AppDomain createDomain (string friendlyName, AppDomainSetup info);
806
807                 [MonoTODO ("Currently it does not allow the setup in the other domain")]
808                 [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
809                 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info)
810                 {
811                         if (friendlyName == null)
812                                 throw new System.ArgumentNullException ("friendlyName");
813
814                         AppDomain def = AppDomain.DefaultDomain;
815                         if (info == null) {
816                                 // if null, get default domain's SetupInformation       
817                                 if (def == null)
818                                         info = new AppDomainSetup ();   // we're default!
819                                 else
820                                         info = def.SetupInformation;
821                         }
822                         else
823                                 info = new AppDomainSetup (info);       // copy
824
825                         // todo: allow setup in the other domain
826                         if (def != null) {
827                                 if (!info.Equals (def.SetupInformation)) {
828                                         // If not specified use default domain's app base.
829                                         if (info.ApplicationBase == null)
830                                                 info.ApplicationBase = def.SetupInformation.ApplicationBase;
831                                         if (info.ConfigurationFile == null)
832                                                 info.ConfigurationFile = Path.GetFileName (def.SetupInformation.ConfigurationFile);
833                                 }
834                         } else if (info.ConfigurationFile == null)
835                                 info.ConfigurationFile = "[I don't have a config file]";
836
837                         AppDomain ad = (AppDomain) RemotingServices.GetDomainProxy (createDomain (friendlyName, info));
838                         if (securityInfo == null) {
839                                 // get default domain's Evidence (unless we're are the default!)
840                                 if (def == null)
841                                         ad._evidence = null;            // we'll get them later (GetEntryAssembly)
842                                 else
843                                         ad._evidence = def.Evidence;    // new (shallow) copy
844                         }
845                         else
846                                 ad._evidence = new Evidence (securityInfo);     // copy
847
848 #if NET_2_0
849                         if (info.AppDomainInitializer != null) {
850                                 if ((info.AppDomainInitializer.Method.Attributes & MethodAttributes.Static) == 0)
851                                         throw new ArgumentException ("Non-static methods cannot be invoked as an appdomain initializer");
852                                 info.AppDomainInitializer (info.AppDomainInitializerArguments);
853                         }
854 #endif
855
856                         return ad;
857                 }
858
859                 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath,
860                                                       string appRelativeSearchPath, bool shadowCopyFiles)
861                 {
862                         AppDomainSetup info = new AppDomainSetup ();
863
864                         info.ApplicationBase = appBasePath;
865                         info.PrivateBinPath = appRelativeSearchPath;
866
867                         if (shadowCopyFiles)
868                                 info.ShadowCopyFiles = "true";
869                         else
870                                 info.ShadowCopyFiles = "false";
871
872                         return CreateDomain (friendlyName, securityInfo, info);
873                 }
874
875 #if NET_2_0
876                 [MonoTODO]
877                 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info,
878                                                       PermissionSet grantSet, params StrongName [] fullTrustAssemblies)
879                 {
880                         throw new NotImplementedException ();
881                 }
882 #endif
883
884                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
885                 private static extern bool InternalIsFinalizingForUnload (int domain_id);
886
887                 public bool IsFinalizingForUnload()
888                 {
889                         return InternalIsFinalizingForUnload (getDomainID ());
890                 }
891
892                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
893                 static extern void InternalUnload (int domain_id);
894
895                 // We do this because if the domain is a transparant proxy this
896                 // will still return the correct domain id.
897                 private int getDomainID ()
898                 {
899                         return Thread.GetDomainID ();
900                 }
901
902                 [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)]
903 #if NET_2_0
904                 [ReliabilityContractAttribute (Consistency.MayCorruptAppDomain, Cer.MayFail)]
905 #endif
906                 public static void Unload (AppDomain domain)
907                 {
908                         if (domain == null)
909                                 throw new ArgumentNullException ("domain");
910
911                         InternalUnload (domain.getDomainID());
912                 }
913
914                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
915                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
916                 public extern void SetData (string name, object data);
917
918 #if NET_2_0
919                 [MonoTODO]
920                 public void SetData (string name, object data, IPermission permission)
921                 {
922                         throw new NotImplementedException ();
923                 }
924 #endif
925
926 #if NET_2_0
927                 [Obsolete ("Use AppDomainSetup.DynamicBase")]
928 #endif
929                 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
930                 public void SetDynamicBase (string path)
931                 {
932                         SetupInformationNoCopy.DynamicBase = path;
933                 }
934
935 #if NET_2_0
936                 [Obsolete ("AppDomain.GetCurrentThreadId has been deprecated"
937                         + " because it does not provide a stable Id when managed"
938                         + " threads are running on fibers (aka lightweight"
939                         + " threads). To get a stable identifier for a managed"
940                         + " thread, use the ManagedThreadId property on Thread.'")]
941 #endif
942                 public static int GetCurrentThreadId ()
943                 {
944                         return Thread.CurrentThreadId;
945                 }
946
947                 public override string ToString ()
948                 {
949                         return getFriendlyName ();
950                 }
951
952                 private static void ValidateAssemblyName (string name)
953                 {
954                         if (name == null || name.Length == 0)
955                                 throw new ArgumentException ("The Name of " +
956                                         "AssemblyName cannot be null or a " +
957                                         "zero-length string.");
958
959                         bool isValid = true;
960
961                         for (int i = 0; i < name.Length; i++) {
962                                 char c = name [i];
963
964                                 // do not allow leading whitespace
965                                 if (i == 0 && char.IsWhiteSpace (c)) {
966                                         isValid = false;
967                                         break;
968                                 }
969
970                                 // do not allow /,\ or : in name
971                                 if (c == '/' || c == '\\' || c == ':') {
972                                         isValid = false;
973                                         break;
974                                 }
975                         }
976
977                         if (!isValid)
978                                 throw new ArgumentException ("The Name of " +
979                                         "AssemblyName cannot start with " +
980                                         "whitespace, or contain '/', '\\' " +
981                                         " or ':'.");
982                 }
983
984                 // The following methods are called from the runtime. Don't change signatures.
985                 private void DoAssemblyLoad (Assembly assembly)
986                 {
987                         if (AssemblyLoad == null)
988                                 return;
989
990                         AssemblyLoad (this, new AssemblyLoadEventArgs (assembly));
991                 }
992
993                 private Assembly DoAssemblyResolve (string name, bool refonly)
994                 {
995                         ResolveEventHandler del;
996 #if NET_2_0
997                         if (refonly)
998                                 del = ReflectionOnlyAssemblyResolve;
999                         else
1000                                 del = AssemblyResolve;
1001 #else
1002                         del = AssemblyResolve;
1003 #endif
1004                         if (del == null)
1005                                 return null;
1006                         
1007                         /* Prevent infinite recursion */
1008                         Hashtable ht = assembly_resolve_in_progress;
1009                         if (ht == null) {
1010                                 ht = new Hashtable ();
1011                                 assembly_resolve_in_progress = ht;
1012                         }
1013
1014                         Assembly ass = (Assembly) ht [name];
1015 #if NET_2_0
1016                         if (ass != null && (ass.ReflectionOnly == refonly))
1017                                 return null;
1018 #else
1019                         if (ass != null)
1020                                 return null;
1021 #endif
1022                         ht [name] = name;
1023                         try {
1024                                 Delegate[] invocation_list = del.GetInvocationList ();
1025
1026                                 foreach (Delegate eh in invocation_list) {
1027                                         ResolveEventHandler handler = (ResolveEventHandler) eh;
1028                                         Assembly assembly = handler (this, new ResolveEventArgs (name));
1029                                         if (assembly != null)
1030                                                 return assembly;
1031                                 }
1032                                 return null;
1033                         }
1034                         finally {
1035                                 ht.Remove (name);
1036                         }
1037                 }
1038
1039                 internal Assembly DoTypeResolve (Object name_or_tb)
1040                 {
1041                         if (TypeResolve == null)
1042                                 return null;
1043
1044                         string name;
1045
1046                         if (name_or_tb is TypeBuilder)
1047                                 name = ((TypeBuilder) name_or_tb).FullName;
1048                         else
1049                                 name = (string) name_or_tb;
1050
1051                         /* Prevent infinite recursion */
1052                         Hashtable ht = type_resolve_in_progress;
1053                         if (ht == null) {
1054                                 ht = new Hashtable ();
1055                                 type_resolve_in_progress = ht;
1056                         }
1057
1058                         if (ht.Contains (name))
1059                                 return null;
1060                         else
1061                                 ht [name] = name;
1062
1063                         try {
1064                                 foreach (Delegate d in TypeResolve.GetInvocationList ()) {
1065                                         ResolveEventHandler eh = (ResolveEventHandler) d;
1066                                         Assembly assembly = eh (this, new ResolveEventArgs (name));
1067                                         if (assembly != null)
1068                                                 return assembly;
1069                                 }
1070                                 return null;
1071                         }
1072                         finally {
1073                                 ht.Remove (name);
1074                         }
1075                 }
1076
1077                 private void DoDomainUnload ()
1078                 {
1079                         if (DomainUnload != null)
1080                                 DomainUnload(this, null);
1081                 }
1082
1083                 internal byte[] GetMarshalledDomainObjRef ()
1084                 {
1085                         ObjRef oref = RemotingServices.Marshal (AppDomain.CurrentDomain, null, typeof (AppDomain));
1086                         return CADSerializer.SerializeObject (oref).GetBuffer();
1087                 }
1088
1089                 internal void ProcessMessageInDomain (byte[] arrRequest, CADMethodCallMessage cadMsg,
1090                                                       out byte[] arrResponse, out CADMethodReturnMessage cadMrm)
1091                 {
1092                         IMessage reqDomMsg;
1093
1094                         if (null != arrRequest)
1095                                 reqDomMsg = CADSerializer.DeserializeMessage (new MemoryStream(arrRequest), null);
1096                         else
1097                                 reqDomMsg = new MethodCall (cadMsg);
1098
1099                         IMessage retDomMsg = ChannelServices.SyncDispatchMessage (reqDomMsg);
1100
1101                         cadMrm = CADMethodReturnMessage.Create (retDomMsg);
1102                         if (null == cadMrm) {
1103                                 arrResponse = CADSerializer.SerializeMessage (retDomMsg).GetBuffer();
1104                         } 
1105                         else
1106                                 arrResponse = null;
1107                 }
1108
1109                 // End of methods called from the runtime
1110                 
1111 #if BOOTSTRAP_WITH_OLDLIB
1112                 // older MCS/corlib returns:
1113                 // _AppDomain.cs(138) error CS0592: Attribute 'SecurityPermission' is not valid on this declaration type.
1114                 // It is valid on 'assembly' 'class' 'constructor' 'method' 'struct'  declarations only.
1115                 public event AssemblyLoadEventHandler AssemblyLoad;
1116
1117                 public event ResolveEventHandler AssemblyResolve;
1118
1119                 public event EventHandler DomainUnload;
1120
1121                 public event EventHandler ProcessExit;
1122
1123                 public event ResolveEventHandler ResourceResolve;
1124
1125                 public event ResolveEventHandler TypeResolve;
1126
1127                 public event UnhandledExceptionEventHandler UnhandledException;
1128 #else
1129                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1130                 public event AssemblyLoadEventHandler AssemblyLoad;
1131
1132                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1133                 public event ResolveEventHandler AssemblyResolve;
1134
1135                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1136                 public event EventHandler DomainUnload;
1137
1138                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1139                 public event EventHandler ProcessExit;
1140
1141                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1142                 public event ResolveEventHandler ResourceResolve;
1143
1144                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1145                 public event ResolveEventHandler TypeResolve;
1146
1147                 [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
1148                 public event UnhandledExceptionEventHandler UnhandledException;
1149 #endif
1150
1151                 /* Avoid warnings for events used only by the runtime */
1152                 private void DummyUse () {
1153                         ProcessExit += (EventHandler)null;
1154                         ResourceResolve += (ResolveEventHandler)null;
1155                         UnhandledException += (UnhandledExceptionEventHandler)null;
1156                 }
1157
1158 #if NET_2_0
1159
1160                 public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
1161                 
1162                 private ActivationContext _activation;
1163                 private ApplicationIdentity _applicationIdentity;
1164                 private AppDomainManager _domain_manager;
1165
1166                 // properties
1167
1168                 public ActivationContext ActivationContext {
1169                         get { return _activation; }
1170                 }
1171
1172                 public ApplicationIdentity ApplicationIdentity {
1173                         get { return _applicationIdentity; }
1174                 }
1175
1176                 // default is null
1177                 public AppDomainManager DomainManager {
1178                         get { return _domain_manager; }
1179                 }
1180
1181                 public int Id {
1182                         [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
1183                         get { return getDomainID (); }
1184                 }
1185
1186                 // methods
1187
1188                 [MonoTODO ("This routine only returns the parameter currently")]
1189                 [ComVisible (false)]
1190                 public string ApplyPolicy (string assemblyName)
1191                 {
1192                         if (assemblyName == null)
1193                                 throw new ArgumentNullException ("assemblyName");
1194                         if (assemblyName.Length == 0) // String.Empty
1195                                 throw new ArgumentException ("assemblyName");
1196                         return assemblyName;
1197                 }
1198
1199                 // static methods
1200
1201                 [MonoTODO ("add support for new delegate")]
1202                 public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath,
1203                         string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs)
1204                 {
1205                         return CreateDomain (friendlyName, securityInfo, appBasePath, appRelativeSearchPath, shadowCopyFiles);
1206                 }
1207
1208                 public int ExecuteAssemblyByName (string assemblyName)
1209                 {
1210                         return ExecuteAssemblyByName (assemblyName, null, null);
1211                 }
1212
1213                 public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity)
1214                 {
1215                         return ExecuteAssemblyByName (assemblyName, assemblySecurity, null);
1216                 }
1217
1218                 public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity, params string[] args)
1219                 {
1220                         Assembly a = Assembly.Load (assemblyName, assemblySecurity);
1221
1222                         return ExecuteAssemblyInternal (a, args);
1223                 }
1224
1225                 public int ExecuteAssemblyByName (AssemblyName assemblyName, Evidence assemblySecurity, params string[] args)
1226                 {
1227                         Assembly a = Assembly.Load (assemblyName, assemblySecurity);
1228
1229                         return ExecuteAssemblyInternal (a, args);
1230                 }
1231
1232                 public bool IsDefaultAppDomain ()
1233                 {
1234                         return Object.ReferenceEquals (this, DefaultDomain);
1235                 }
1236
1237                 public Assembly[] ReflectionOnlyGetAssemblies ()
1238                 {
1239                         return GetAssemblies (true);
1240                 }
1241 #endif
1242
1243 #if NET_1_1
1244                 void _AppDomain.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
1245                 {
1246                         throw new NotImplementedException ();
1247                 }
1248
1249                 void _AppDomain.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
1250                 {
1251                         throw new NotImplementedException ();
1252                 }
1253
1254                 void _AppDomain.GetTypeInfoCount (out uint pcTInfo)
1255                 {
1256                         throw new NotImplementedException ();
1257                 }
1258
1259                 void _AppDomain.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
1260                         IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
1261                 {
1262                         throw new NotImplementedException ();
1263                 }
1264 #endif
1265         }
1266 }