2 // AppDomainTest.cs - NUnit Test Cases for AppDomain
5 // Sebastien Pouliot (sebastien@ximian.com)
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using NUnit.Framework;
31 using System.Collections;
32 using System.Globalization;
34 using System.Reflection;
35 using System.Reflection.Emit;
36 using System.Security;
37 using System.Security.Permissions;
38 using System.Security.Policy;
39 using System.Security.Principal;
41 namespace MonoTests.System
44 public class AppDomainTest
47 private ArrayList files = new ArrayList ();
48 private string tempDir = Path.Combine (Path.GetTempPath (), "MonoTests.System.AppDomainTest");
53 if (!Directory.Exists (tempDir)) {
54 Directory.CreateDirectory (tempDir);
59 public void TearDown ()
63 AppDomain.Unload (ad);
65 } catch { } // do not affect unit test results in TearDown
67 foreach (string fname in files) {
74 public void SetThreadPrincipal ()
76 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
77 IPrincipal p = new GenericPrincipal (i, null);
78 ad = AppDomain.CreateDomain ("SetThreadPrincipal");
79 ad.SetThreadPrincipal (p);
83 [ExpectedException (typeof (ArgumentNullException))]
84 public void SetThreadPrincipalNull ()
86 AppDomain.CurrentDomain.SetThreadPrincipal (null);
90 [ExpectedException (typeof (PolicyException))]
91 public void SetThreadPrincipalTwice ()
93 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
94 IPrincipal p = new GenericPrincipal (i, null);
95 ad = AppDomain.CreateDomain ("SetThreadPrincipalTwice");
96 ad.SetThreadPrincipal (p);
97 // you only live twice (or so James told me ;-)
98 ad.SetThreadPrincipal (p);
102 [ExpectedException (typeof (AppDomainUnloadedException))]
103 public void SetThreadPrincipalUnloaded ()
105 ad = AppDomain.CreateDomain ("Ximian");
106 AppDomain.Unload (ad);
107 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
108 IPrincipal p = new GenericPrincipal (i, null);
109 ad.SetThreadPrincipal (p);
113 public void SetPrincipalPolicy_NoPrincipal ()
115 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.NoPrincipal);
119 public void SetPrincipalPolicy_UnauthenticatedPrincipal ()
121 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.UnauthenticatedPrincipal);
125 public void SetPrincipalPolicy_WindowsPrincipal ()
127 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.WindowsPrincipal);
131 [ExpectedException (typeof (AppDomainUnloadedException))]
132 public void SetPrincipalPolicyUnloaded ()
134 ad = AppDomain.CreateDomain ("Ximian");
135 AppDomain.Unload (ad);
136 ad.SetPrincipalPolicy (PrincipalPolicy.NoPrincipal);
140 public void CreateDomain_String ()
142 ad = AppDomain.CreateDomain ("CreateDomain_String");
143 Assert.IsNotNull (ad.Evidence, "Evidence");
144 // Evidence are copied (or referenced?) from default app domain
145 // we can't get default so we use the current (which should have copied the default)
146 Assert.AreEqual (AppDomain.CurrentDomain.Evidence.Count, ad.Evidence.Count, "Evidence.Count");
150 [ExpectedException (typeof (ArgumentNullException))]
151 public void CreateDomain_String_Null ()
153 ad = AppDomain.CreateDomain (null);
157 [Category ("NotDotNet")]
158 public void CreateDomain_StringEvidence ()
160 Evidence e = new Evidence ();
161 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidence", e);
162 Assert.IsNotNull (ad.Evidence, "Evidence");
163 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
165 e.AddHost (new Zone (SecurityZone.MyComputer));
166 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
167 // evidence isn't copied but referenced
171 [ExpectedException (typeof (ArgumentNullException))]
172 public void CreateDomain_StringNullEvidence ()
174 ad = AppDomain.CreateDomain (null, new Evidence ());
178 public void CreateDomain_StringEvidenceNull ()
180 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceNull", null);
181 Assert.IsNotNull (ad.Evidence, "Evidence");
182 // Evidence are copied (or referenced?) from default app domain
183 // we can't get default so we use the current (which should have copied the default)
184 Evidence e = AppDomain.CurrentDomain.Evidence;
185 Assert.AreEqual (e.Count, ad.Evidence.Count, "Evidence.Count-1");
186 e.AddHost (new Zone (SecurityZone.MyComputer));
187 Assert.AreEqual (e.Count - 1, ad.Evidence.Count, "Evidence.Count-2");
188 // evidence are copied
192 [Category ("NotDotNet")]
193 public void CreateDomain_StringEvidenceAppDomainSetup ()
195 Evidence e = new Evidence ();
196 AppDomainSetup info = new AppDomainSetup ();
197 info.ApplicationName = "ApplicationName";
199 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceAppDomainSetup", e, info);
200 Assert.IsNotNull (ad.Evidence, "Evidence");
201 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
202 Assert.IsNotNull (ad.SetupInformation, "SetupInformation");
203 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName);
205 e.AddHost (new Zone (SecurityZone.MyComputer));
206 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
207 // evidence isn't copied but referenced
211 [ExpectedException (typeof (ArgumentNullException))]
212 public void CreateDomain_StringNullEvidenceAppDomainSetup ()
214 AppDomainSetup info = new AppDomainSetup ();
215 ad = AppDomain.CreateDomain (null, new Evidence (), info);
219 public void CreateDomain_StringEvidenceNullAppDomainSetup ()
221 AppDomainSetup info = new AppDomainSetup ();
222 info.ApplicationName = "ApplicationName";
223 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceNullAppDomainSetup", null, info);
224 Assert.IsNotNull (ad.Evidence, "Evidence");
225 // Evidence are copied (or referenced?) from default app domain
226 // we can't get default so we use the current (which should have copied the default)
227 Assert.AreEqual (AppDomain.CurrentDomain.Evidence.Count, ad.Evidence.Count, "Evidence.Count");
228 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName, "ApplicationName-1");
229 info.ApplicationName = "Test";
230 Assert.AreEqual ("Test", info.ApplicationName, "ApplicationName-2");
231 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName, "ApplicationName-3");
236 [Category ("NotDotNet")]
237 public void CreateDomain_StringEvidenceAppDomainSetupNull ()
239 Evidence e = new Evidence ();
240 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceAppDomainSetupNull", e, null);
241 Assert.IsNotNull (ad.Evidence, "Evidence");
242 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
243 // SetupInformation is copied from default app domain
244 Assert.IsNotNull (ad.SetupInformation, "SetupInformation");
248 [Category ("NotWorking")]
249 public void Load_Loaded_Ignore ()
251 int assemblyStartCount = AppDomain.CurrentDomain.GetAssemblies ().Length;
255 string assemblyFile = Path.Combine (tempDir, "bug79720A.dll");
256 AssemblyName aname = new AssemblyName ();
257 aname.Name = "bug79720A";
258 aname.Version = new Version (2, 4);
260 GenerateAssembly (aname, assemblyFile);
262 Assert.AreEqual (assemblyStartCount, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A1");
264 aname = new AssemblyName ();
265 aname.Name = "bug79720A";
267 AppDomain.CurrentDomain.Load (aname);
269 } catch (FileNotFoundException) {
272 aname = new AssemblyName ();
273 aname.Name = "bug79720A";
274 aname.Version = new Version (0, 0, 0, 0);
276 AppDomain.CurrentDomain.Load (aname);
278 } catch (FileNotFoundException) {
281 aname = new AssemblyName ();
282 aname.Name = "bug79720A";
283 aname.Version = new Version (2, 4);
285 AppDomain.CurrentDomain.Load (aname);
287 } catch (FileNotFoundException) {
290 Assert.AreEqual (assemblyStartCount, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A5");
292 Assembly.LoadFrom (assemblyFile);
294 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A6");
296 aname = new AssemblyName ();
297 aname.Name = "bug79720A";
299 AppDomain.CurrentDomain.Load (aname);
301 } catch (FileNotFoundException) {
304 aname = new AssemblyName ();
305 aname.Name = "bug79720A";
306 aname.Version = new Version (0, 0, 0, 0);
308 AppDomain.CurrentDomain.Load (aname);
310 } catch (FileNotFoundException) {
313 aname = new AssemblyName ();
314 aname.Name = "bug79720A";
315 aname.Version = new Version (2, 4);
317 AppDomain.CurrentDomain.Load (aname);
319 } catch (FileNotFoundException) {
322 aname = new AssemblyName ();
323 aname.Name = "bug79720A";
324 aname.Version = new Version (2, 4);
325 aname.CultureInfo = CultureInfo.InvariantCulture;
327 AppDomain.CurrentDomain.Load (aname);
328 Assert.Fail ("#A10");
329 } catch (FileNotFoundException) {
332 aname = new AssemblyName ();
333 aname.Name = "bug79720A";
334 aname.Version = new Version (2, 4, 0, 0);
335 aname.CultureInfo = CultureInfo.InvariantCulture;
337 AppDomain.CurrentDomain.Load (aname);
338 Assert.Fail ("#A11");
339 } catch (FileNotFoundException) {
342 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A12");
346 assemblyFile = Path.Combine (tempDir, "bug79720B.dll");
347 aname = new AssemblyName ();
348 aname.Name = "bug79720B";
349 aname.Version = new Version (2, 4, 1);
350 aname.CultureInfo = new CultureInfo ("nl-BE");
352 GenerateAssembly (aname, assemblyFile);
354 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B1");
356 aname = new AssemblyName ();
357 aname.Name = "bug79720B";
359 AppDomain.CurrentDomain.Load (aname);
361 } catch (FileNotFoundException) {
364 aname = new AssemblyName ();
365 aname.Name = "bug79720B";
366 aname.Version = new Version (0, 0, 0, 0);
368 AppDomain.CurrentDomain.Load (aname);
370 } catch (FileNotFoundException) {
373 aname = new AssemblyName ();
374 aname.Name = "bug79720B";
375 aname.Version = new Version (2, 4, 1);
377 AppDomain.CurrentDomain.Load (aname);
379 } catch (FileNotFoundException) {
382 aname = new AssemblyName ();
383 aname.Name = "bug79720B";
384 aname.Version = new Version (2, 4, 1);
385 aname.CultureInfo = new CultureInfo ("nl-BE");
387 AppDomain.CurrentDomain.Load (aname);
389 } catch (FileNotFoundException) {
392 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B6");
394 Assembly.LoadFrom (assemblyFile);
396 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B7");
398 aname = new AssemblyName ();
399 aname.Name = "bug79720B";
401 AppDomain.CurrentDomain.Load (aname);
403 } catch (FileNotFoundException) {
406 aname = new AssemblyName ();
407 aname.Name = "bug79720B";
408 aname.Version = new Version (0, 0, 0, 0);
410 AppDomain.CurrentDomain.Load (aname);
412 } catch (FileNotFoundException) {
415 aname = new AssemblyName ();
416 aname.Name = "bug79720B";
417 aname.Version = new Version (2, 4, 1);
419 AppDomain.CurrentDomain.Load (aname);
420 Assert.Fail ("#B10");
421 } catch (FileNotFoundException) {
424 aname = new AssemblyName ();
425 aname.Name = "bug79720B";
426 aname.Version = new Version (2, 4, 1);
427 aname.CultureInfo = new CultureInfo ("nl-BE");
429 AppDomain.CurrentDomain.Load (aname);
430 Assert.Fail ("#B11");
431 } catch (FileNotFoundException) {
434 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B12");
438 assemblyFile = Path.Combine (tempDir, "bug79720C.dll");
439 aname = new AssemblyName ();
440 aname.Name = "bug79720C";
441 aname.CultureInfo = new CultureInfo ("nl-BE");
442 aname.Version = new Version (2, 4);
443 aname.KeyPair = new StrongNameKeyPair (keyPair);
445 GenerateAssembly (aname, assemblyFile);
447 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C1");
449 aname = new AssemblyName ();
450 aname.Name = "bug79720C";
452 AppDomain.CurrentDomain.Load (aname);
454 } catch (FileNotFoundException) {
457 aname = new AssemblyName ();
458 aname.Name = "bug79720C";
459 aname.Version = new Version (0, 0, 0, 0);
461 AppDomain.CurrentDomain.Load (aname);
463 } catch (FileNotFoundException) {
466 aname = new AssemblyName ();
467 aname.Name = "bug79720C";
468 aname.Version = new Version (2, 4, 1);
470 AppDomain.CurrentDomain.Load (aname);
472 } catch (FileNotFoundException) {
475 aname = new AssemblyName ();
476 aname.Name = "bug79720C";
477 aname.Version = new Version (2, 4, 1);
478 aname.CultureInfo = new CultureInfo ("nl-BE");
480 AppDomain.CurrentDomain.Load (aname);
482 } catch (FileNotFoundException) {
485 aname = new AssemblyName ();
486 aname.Name = "bug79720C";
487 aname.Version = new Version (2, 4, 1);
488 aname.CultureInfo = new CultureInfo ("nl-BE");
489 aname.SetPublicKey (publicKey);
491 AppDomain.CurrentDomain.Load (aname);
493 } catch (FileNotFoundException) {
496 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C7");
498 Assembly.LoadFrom (assemblyFile);
500 Assert.AreEqual (assemblyStartCount + 3, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C8");
502 aname = new AssemblyName ();
503 aname.Name = "bug79720C";
505 AppDomain.CurrentDomain.Load (aname);
507 } catch (FileNotFoundException) {
510 aname = new AssemblyName ();
511 aname.Name = "bug79720C";
512 aname.Version = new Version (0, 0, 0, 0);
514 AppDomain.CurrentDomain.Load (aname);
515 Assert.Fail ("#C10");
516 } catch (FileNotFoundException) {
519 aname = new AssemblyName ();
520 aname.Name = "bug79720C";
521 aname.Version = new Version (2, 4);
523 AppDomain.CurrentDomain.Load (aname);
524 Assert.Fail ("#C11");
525 } catch (FileNotFoundException) {
528 aname = new AssemblyName ();
529 aname.Name = "bug79720C";
530 aname.Version = new Version (2, 4);
531 aname.CultureInfo = new CultureInfo ("nl-BE");
533 AppDomain.CurrentDomain.Load (aname);
534 Assert.Fail ("#C12");
535 } catch (FileNotFoundException) {
538 aname = new AssemblyName ();
539 aname.Name = "bug79720C";
540 aname.Version = new Version (2, 4);
541 aname.CultureInfo = new CultureInfo ("nl-BE");
542 aname.SetPublicKey (publicKey);
544 AppDomain.CurrentDomain.Load (aname);
545 Assert.Fail ("#C13");
546 } catch (FileNotFoundException) {
549 Assert.AreEqual (assemblyStartCount + 3, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C14");
553 [Category ("NotWorking")]
554 public void Load_Loaded_Multiple ()
556 string cultureDir = Path.Combine (tempDir, "nl-BE");
557 if (!Directory.Exists (cultureDir))
558 Directory.CreateDirectory (cultureDir);
560 AppDomain ad = CreateTestDomain (tempDir, true);
562 CrossDomainTester cdt = CreateCrossDomainTester (ad);
564 int assemblyCount = cdt.AssemblyCount;
568 AssemblyName aname = new AssemblyName ();
569 aname.Name = "multipleA";
570 aname.Version = new Version (1, 2, 3, 4);
571 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "multipleA.dll"));
573 Assert.AreEqual (assemblyCount + 1, cdt.AssemblyCount, "#A1");
575 aname = new AssemblyName ();
576 aname.Name = "multipleA";
577 Assert.IsTrue (cdt.AssertLoad (aname), "#A2");
579 Assert.AreEqual (assemblyCount + 2, cdt.AssemblyCount, "#A3");
581 aname = new AssemblyName ();
582 aname.Name = "multipleA";
583 Assert.IsTrue (cdt.AssertLoad (aname), "#A4");
585 aname = new AssemblyName ();
586 aname.Name = "multipleA";
587 aname.CultureInfo = CultureInfo.InvariantCulture;
588 Assert.IsTrue (cdt.AssertLoad (aname), "#A5");
590 aname = new AssemblyName ();
591 aname.Name = "multipleA";
592 aname.CultureInfo = CultureInfo.InvariantCulture;
593 Assert.IsTrue (cdt.AssertLoad (aname), "#A6");
595 aname = new AssemblyName ();
596 aname.Name = "multipleA";
597 aname.CultureInfo = CultureInfo.InvariantCulture;
598 aname.Version = new Version (1, 2, 3, 4);
599 Assert.IsTrue (cdt.AssertLoad (aname), "#A7");
601 aname = new AssemblyName ();
602 aname.Name = "multipleA";
603 aname.CultureInfo = CultureInfo.InvariantCulture;
604 aname.Version = new Version (1, 2, 3, 4);
605 Assert.IsTrue (cdt.AssertLoad (aname), "#A8");
607 Assert.AreEqual (assemblyCount + 2, cdt.AssemblyCount, "#A9");
611 aname = new AssemblyName ();
612 aname.Name = "multipleB";
613 aname.CultureInfo = new CultureInfo ("nl-BE");
614 aname.Version = new Version (2, 4, 1, 0);
615 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "nl-BE/multipleB.dll"));
617 Assert.AreEqual (assemblyCount + 3, cdt.AssemblyCount, "#B1");
619 aname = new AssemblyName ();
620 aname.Name = "multipleB";
621 Assert.IsTrue (cdt.AssertLoad (aname), "#B2");
623 Assert.AreEqual (assemblyCount + 4, cdt.AssemblyCount, "#B3");
625 aname = new AssemblyName ();
626 aname.Name = "multipleB";
627 Assert.IsTrue (cdt.AssertLoad (aname), "#B4");
629 aname = new AssemblyName ();
630 aname.Name = "multipleB";
631 aname.CultureInfo = new CultureInfo ("nl-BE");
632 Assert.IsTrue (cdt.AssertLoad (aname), "#B5");
634 aname = new AssemblyName ();
635 aname.Name = "multipleB";
636 aname.CultureInfo = new CultureInfo ("nl-BE");
637 Assert.IsTrue (cdt.AssertLoad (aname), "#B6");
639 aname = new AssemblyName ();
640 aname.Name = "multipleB";
641 aname.CultureInfo = new CultureInfo ("nl-BE");
642 aname.Version = new Version (2, 4, 1, 0);
643 Assert.IsTrue (cdt.AssertLoad (aname), "#B7");
645 aname = new AssemblyName ();
646 aname.Name = "multipleB";
647 aname.CultureInfo = new CultureInfo ("nl-BE");
648 aname.Version = new Version (2, 4, 1, 0);
649 Assert.IsTrue (cdt.AssertLoad (aname), "#B8");
651 Assert.AreEqual (assemblyCount + 4, cdt.AssemblyCount, "#B9");
655 aname = new AssemblyName ();
656 aname.Name = "multipleC";
657 aname.CultureInfo = new CultureInfo ("nl-BE");
658 aname.Version = new Version (2, 4, 0, 0);
659 aname.KeyPair = new StrongNameKeyPair (keyPair);
660 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "nl-BE/multipleC.dll"));
662 Assert.AreEqual (assemblyCount + 5, cdt.AssemblyCount, "#C1");
664 aname = new AssemblyName ();
665 aname.Name = "multipleC";
666 aname.CultureInfo = new CultureInfo ("nl-BE");
667 aname.Version = new Version (2, 4, 0, 0);
668 aname.SetPublicKey (publicKey);
669 Assert.IsTrue (cdt.AssertLoad (aname), "#C2");
671 Assert.AreEqual (assemblyCount + 6, cdt.AssemblyCount, "#C3");
673 aname = new AssemblyName ();
674 aname.Name = "multipleC";
675 aname.CultureInfo = new CultureInfo ("nl-BE");
676 aname.Version = new Version (2, 4, 0, 0);
677 aname.SetPublicKey (publicKey);
678 Assert.IsTrue (cdt.AssertLoad (aname), "#C4");
680 Assert.AreEqual (assemblyCount + 6, cdt.AssemblyCount, "#C5");
682 AppDomain.Unload (ad);
687 [Category ("NotWorking")]
688 public void Load_Manifest_Mismatch ()
690 string assemblyFile = Path.Combine (tempDir, "bug79522A.dll");
691 AssemblyName aname = new AssemblyName ();
692 aname.Name = "bug79522A";
693 aname.Version = new Version (2, 4);
695 GenerateAssembly (aname, assemblyFile);
697 aname = new AssemblyName ();
698 aname.CodeBase = assemblyFile;
699 aname.Name = "whateveryouwant";
700 aname.Version = new Version (1, 1);
702 // despite the fact that no assembly with the specified name
703 // exists, the assembly pointed to by the CodeBase of the
704 // AssemblyName will be loaded
706 // however the display name of the loaded assembly does not
707 // match the display name of the AssemblyName, and as a result
708 // a FileLoadException is thrown
710 AppDomain.CurrentDomain.Load (aname);
712 } catch (FileLoadException) {
715 // if we set CodeBase to some garbage, then we'll get a
716 // FileNotFoundException instead
717 aname.CodeBase = "whatever";
719 AppDomain.CurrentDomain.Load (aname);
721 } catch (FileNotFoundException) {
724 aname = new AssemblyName ();
725 aname.Name = "bug79522A";
726 aname.CodeBase = assemblyFile;
728 AppDomain.CurrentDomain.Load (aname);
731 AppDomain.CurrentDomain.Load (aname);
733 } catch (FileLoadException) {
737 aname = new AssemblyName ();
738 aname.Name = "bug79522A";
739 aname.CodeBase = assemblyFile;
740 aname.Version = new Version (2, 5);
742 // the version number is not considered when comparing the manifest
743 // of the assembly found using codebase
744 AppDomain.CurrentDomain.Load (aname);
747 AppDomain.CurrentDomain.Load (aname);
749 } catch (FileLoadException) {
753 aname = new AssemblyName ();
754 aname.Name = "bug79522A";
755 aname.CodeBase = assemblyFile;
756 aname.Version = new Version (2, 4, 1);
758 // the version number is not considered when comparing the manifest
759 // of the assembly found using codebase
760 AppDomain.CurrentDomain.Load (aname);
763 AppDomain.CurrentDomain.Load (aname);
765 } catch (FileLoadException) {
769 // if version is set, then culture must also be set
770 aname = new AssemblyName ();
771 aname.Name = "bug79522A";
772 aname.CodeBase = assemblyFile;
773 aname.Version = new Version (2, 4);
775 AppDomain.CurrentDomain.Load (aname);
778 AppDomain.CurrentDomain.Load (aname);
780 } catch (FileLoadException) {
784 // version number does not need to be set
785 aname = new AssemblyName ();
786 aname.Name = "bug79522A";
787 aname.CodeBase = assemblyFile;
788 aname.CultureInfo = CultureInfo.InvariantCulture;
789 AppDomain.CurrentDomain.Load (aname);
791 // if set, the version number must match exactly
792 aname = new AssemblyName ();
793 aname.Name = "bug79522A";
794 aname.CodeBase = assemblyFile;
795 aname.CultureInfo = CultureInfo.InvariantCulture;
796 aname.Version = new Version (2, 4);
797 AppDomain.CurrentDomain.Load (aname);
799 // if both culture and version are set, then the version diff
801 aname = new AssemblyName ();
802 aname.Name = "bug79522A";
803 aname.CodeBase = assemblyFile;
804 aname.CultureInfo = CultureInfo.InvariantCulture;
805 aname.Version = new Version (2, 5);
806 AppDomain.CurrentDomain.Load (aname);
808 // loaded assembly is not signed
809 aname = new AssemblyName ();
810 aname.Name = "bug79522A";
811 aname.CodeBase = assemblyFile;
812 aname.CultureInfo = CultureInfo.InvariantCulture;
813 aname.Version = new Version (2, 4);
814 aname.SetPublicKey (publicKey);
816 AppDomain.CurrentDomain.Load (aname);
818 } catch (FileLoadException) {
821 // if set, the culture must match
822 aname = new AssemblyName ();
823 aname.Name = "bug79522A";
824 aname.CodeBase = assemblyFile;
825 aname.Version = new Version (2, 4);
826 aname.CultureInfo = new CultureInfo ("en-US");
828 AppDomain.CurrentDomain.Load (aname);
830 } catch (FileLoadException) {
835 assemblyFile = Path.Combine (tempDir, "bug79522B.dll");
836 aname = new AssemblyName ();
837 aname.Name = "bug79522B";
838 aname.CultureInfo = new CultureInfo ("nl-BE");
839 aname.Version = new Version (2, 4, 1);
841 GenerateAssembly (aname, assemblyFile);
843 aname = new AssemblyName ();
844 aname.CodeBase = assemblyFile;
845 aname.Name = "whateveryouwant";
846 aname.CultureInfo = new CultureInfo ("nl-BE");
847 aname.Version = new Version (1, 1);
849 // despite the fact that no assembly with the specified name
850 // exists, the assembly pointed to by the CodeBase of the
851 // AssemblyName will be loaded
853 // however the display name of the loaded assembly does not
854 // match the display name of the AssemblyName, and as a result
855 // a FileLoadException is thrown
857 AppDomain.CurrentDomain.Load (aname);
859 } catch (FileLoadException) {
862 // if we set CodeBase to some garbage, then we'll get a
863 // FileNotFoundException instead
864 aname.CodeBase = "whatever";
866 AppDomain.CurrentDomain.Load (aname);
868 } catch (FileNotFoundException) {
871 aname = new AssemblyName ();
872 aname.Name = "bug79522B";
873 aname.CodeBase = assemblyFile;
875 // the version number is not considered when comparing the manifest
876 // of the assembly found using codebase
877 AppDomain.CurrentDomain.Load (aname);
880 AppDomain.CurrentDomain.Load (aname);
882 } catch (FileLoadException) {
886 aname = new AssemblyName ();
887 aname.Name = "bug79522B";
888 aname.CodeBase = assemblyFile;
889 aname.Version = new Version (5, 5);
891 // the version number is not considered when comparing the manifest
892 // of the assembly found using codebase
893 AppDomain.CurrentDomain.Load (aname);
896 AppDomain.CurrentDomain.Load (aname);
898 } catch (FileLoadException) {
902 aname = new AssemblyName ();
903 aname.Name = "bug79522B";
904 aname.CodeBase = assemblyFile;
905 aname.Version = new Version (2, 4, 1);
907 AppDomain.CurrentDomain.Load (aname);
909 // when the loaded assembly has a specific culture, then that
910 // culture must be set if you set the Version on the aname
912 AppDomain.CurrentDomain.Load (aname);
914 } catch (FileLoadException) {
918 // version does not need to be set
919 aname = new AssemblyName ();
920 aname.Name = "bug79522B";
921 aname.CodeBase = assemblyFile;
922 aname.CultureInfo = new CultureInfo ("nl-BE");
923 AppDomain.CurrentDomain.Load (aname);
925 // if both culture and version are set, then the version diff
927 aname = new AssemblyName ();
928 aname.Name = "bug79522B";
929 aname.CodeBase = assemblyFile;
930 aname.CultureInfo = new CultureInfo ("nl-BE");
931 aname.Version = new Version (6, 5);
932 AppDomain.CurrentDomain.Load (aname);
934 // loaded assembly is not signed
935 aname = new AssemblyName ();
936 aname.Name = "bug79522B";
937 aname.CodeBase = assemblyFile;
938 aname.CultureInfo = new CultureInfo ("nl-BE");
939 aname.SetPublicKey (publicKey);
941 AppDomain.CurrentDomain.Load (aname);
943 } catch (FileLoadException) {
946 // if set, the culture must match
947 aname = new AssemblyName ();
948 aname.Name = "bug79522B";
949 aname.CodeBase = assemblyFile;
950 aname.Version = new Version (2, 4, 1);
951 aname.CultureInfo = new CultureInfo ("en-US");
953 AppDomain.CurrentDomain.Load (aname);
955 } catch (FileLoadException) {
960 assemblyFile = Path.Combine (tempDir, "bug79522C.dll");
961 aname = new AssemblyName ();
962 aname.Name = "bug79522C";
963 aname.CultureInfo = new CultureInfo ("nl-BE");
964 aname.Version = new Version (2, 4);
965 aname.KeyPair = new StrongNameKeyPair (keyPair);
967 GenerateAssembly (aname, assemblyFile);
969 aname = new AssemblyName ();
970 aname.CodeBase = assemblyFile;
971 aname.Name = "whateveryouwant";
972 aname.CultureInfo = new CultureInfo ("nl-BE");
973 aname.Version = new Version (1, 1);
974 aname.SetPublicKey (publicKey);
976 // despite the fact that no assembly with the specified name
977 // exists, the assembly pointed to by the CodeBase of the
978 // AssemblyName will be loaded
980 // however the display name of the loaded assembly does not
981 // match the display name of the AssemblyName, and as a result
982 // a FileLoadException is thrown
984 AppDomain.CurrentDomain.Load (aname);
986 } catch (FileLoadException) {
989 // if we set CodeBase to some garbage, then we'll get a
990 // FileNotFoundException instead
991 aname.CodeBase = "whatever";
993 AppDomain.CurrentDomain.Load (aname);
995 } catch (FileNotFoundException) {
998 aname = new AssemblyName ();
999 aname.Name = "bug79522C";
1000 aname.CodeBase = assemblyFile;
1002 AppDomain.CurrentDomain.Load (aname);
1005 AppDomain.CurrentDomain.Load (aname);
1006 Assert.Fail ("#C3");
1007 } catch (FileLoadException) {
1011 aname = new AssemblyName ();
1012 aname.Name = "bug79522C";
1013 aname.CodeBase = assemblyFile;
1014 aname.Version = new Version (5, 5);
1016 AppDomain.CurrentDomain.Load (aname);
1017 Assert.Fail ("#C3");
1018 } catch (FileLoadException) {
1021 aname = new AssemblyName ();
1022 aname.Name = "bug79522C";
1023 aname.CodeBase = assemblyFile;
1024 aname.Version = new Version (2, 4);
1026 AppDomain.CurrentDomain.Load (aname);
1028 // when the loaded assembly has a specific culture/publickey,
1029 // then that culture/publickey must be set if you set the
1030 // Version on the aname
1032 AppDomain.CurrentDomain.Load (aname);
1033 Assert.Fail ("#C4");
1034 } catch (FileLoadException) {
1038 aname = new AssemblyName ();
1039 aname.Name = "bug79522C";
1040 aname.CodeBase = assemblyFile;
1041 aname.CultureInfo = new CultureInfo ("nl-BE");
1042 aname.Version = new Version (2, 4);
1044 AppDomain.CurrentDomain.Load (aname);
1046 // if loaded assembly is signed, then the public key must be set
1048 AppDomain.CurrentDomain.Load (aname);
1049 Assert.Fail ("#C5");
1050 } catch (FileLoadException) {
1054 aname = new AssemblyName ();
1055 aname.Name = "bug79522C";
1056 aname.CodeBase = assemblyFile;
1057 aname.CultureInfo = new CultureInfo ("nl-BE");
1058 aname.SetPublicKey (publicKey);
1060 AppDomain.CurrentDomain.Load (aname);
1062 // if public key is set, then version must be set
1064 AppDomain.CurrentDomain.Load (aname);
1065 Assert.Fail ("#C6");
1066 } catch (FileLoadException) {
1070 aname = new AssemblyName ();
1071 aname.Name = "bug79522C";
1072 aname.CodeBase = assemblyFile;
1073 aname.CultureInfo = new CultureInfo ("nl-BE");
1075 AppDomain.CurrentDomain.Load (aname);
1078 AppDomain.CurrentDomain.Load (aname);
1079 Assert.Fail ("#C7");
1080 } catch (FileLoadException) {
1084 // if culture and version are set, then the version must match
1085 aname = new AssemblyName ();
1086 aname.Name = "bug79522C";
1087 aname.CodeBase = assemblyFile;
1088 aname.CultureInfo = new CultureInfo ("nl-BE");
1089 aname.SetPublicKey (publicKey);
1090 aname.Version = new Version (5, 6);
1092 AppDomain.CurrentDomain.Load (aname);
1093 Assert.Fail ("#C8");
1094 } catch (FileLoadException) {
1097 // publickey must match
1098 aname = new AssemblyName ();
1099 aname.Name = "bug79522C";
1100 aname.CodeBase = assemblyFile;
1101 aname.CultureInfo = new CultureInfo ("nl-BE");
1102 aname.Version = new Version (2, 4);
1103 aname.SetPublicKey (publicKey2);
1105 AppDomain.CurrentDomain.Load (aname);
1106 Assert.Fail ("#C9");
1108 } catch (SecurityException) {
1109 // Invalid assembly public key
1112 } catch (FileLoadException) {
1116 aname = new AssemblyName ();
1117 aname.Name = "bug79522C";
1118 aname.CodeBase = assemblyFile;
1119 aname.SetPublicKey (publicKey);
1120 aname.CultureInfo = new CultureInfo ("nl-BE");
1121 aname.Version = new Version (2, 4);
1122 AppDomain.CurrentDomain.Load (aname);
1125 [Test] // bug #79715
1126 public void Load_PartialVersion ()
1128 AppDomain ad = CreateTestDomain (tempDir, true);
1130 CrossDomainTester cdt = CreateCrossDomainTester (ad);
1132 AssemblyName aname = new AssemblyName ();
1133 aname.Name = "bug79715";
1134 aname.Version = new Version (1, 2, 3, 4);
1135 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "bug79715.dll"));
1137 aname = new AssemblyName ();
1138 aname.Name = "bug79715";
1139 aname.Version = new Version (1, 2);
1140 Assert.IsTrue (cdt.AssertLoad (aname), "#A1");
1141 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#A2");
1143 aname = new AssemblyName ();
1144 aname.Name = "bug79715";
1145 aname.Version = new Version (1, 2, 3);
1146 Assert.IsTrue (cdt.AssertLoad (aname), "#B1");
1147 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#B2");
1149 aname = new AssemblyName ();
1150 aname.Name = "bug79715";
1151 aname.Version = new Version (1, 2, 3, 4);
1152 Assert.IsTrue (cdt.AssertLoad (aname), "#C1");
1153 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#C2");
1155 AppDomain.Unload (ad);
1160 public void SetAppDomainPolicy ()
1162 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Null");
1163 ad.SetAppDomainPolicy (PolicyLevel.CreateAppDomainLevel ());
1168 [ExpectedException (typeof (ArgumentNullException))]
1169 public void SetAppDomainPolicy_Null ()
1171 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Null");
1172 ad.SetAppDomainPolicy (null);
1176 [ExpectedException (typeof (PolicyException))]
1177 public void SetAppDomainPolicy_Dual ()
1179 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Dual");
1180 PolicyLevel pl = PolicyLevel.CreateAppDomainLevel ();
1181 PermissionSet ps = new PermissionSet (PermissionState.Unrestricted);
1182 pl.RootCodeGroup.PolicyStatement = new PolicyStatement (ps);
1183 ad.SetAppDomainPolicy (pl);
1186 pl = PolicyLevel.CreateAppDomainLevel ();
1187 ps = new PermissionSet (PermissionState.None);
1188 pl.RootCodeGroup.PolicyStatement = new PolicyStatement (ps);
1189 ad.SetAppDomainPolicy (pl);
1193 [ExpectedException (typeof (AppDomainUnloadedException))]
1194 public void SetAppDomainPolicy_Unloaded ()
1196 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Unloaded");
1197 AppDomain.Unload (ad);
1198 ad.SetAppDomainPolicy (PolicyLevel.CreateAppDomainLevel ());
1202 [ExpectedException (typeof (ArgumentNullException))]
1203 public void GetData_Null ()
1205 AppDomain.CurrentDomain.GetData (null);
1209 public void SetData ()
1211 AppDomain.CurrentDomain.SetData ("data", "data");
1212 Assert.AreEqual ("data", AppDomain.CurrentDomain.GetData ("data"), "GetData");
1213 AppDomain.CurrentDomain.SetData ("data", null);
1214 Assert.IsNull (AppDomain.CurrentDomain.GetData ("data"), "GetData-Null");
1218 [ExpectedException (typeof (ArgumentNullException))]
1219 public void SetData_Null ()
1221 AppDomain.CurrentDomain.SetData (null, "data");
1226 public void ApplyPolicy ()
1228 ad = AppDomain.CreateDomain ("ApplyPolicy");
1229 string fullname = Assembly.GetExecutingAssembly ().FullName;
1230 string result = ad.ApplyPolicy (fullname);
1231 Assert.AreEqual (fullname, result, "ApplyPolicy");
1232 // doesn't even requires an assembly name
1233 Assert.AreEqual ("123", ad.ApplyPolicy ("123"), "Invalid FullName");
1237 [ExpectedException (typeof (ArgumentException))]
1238 public void ApplyPolicy_Empty ()
1240 ad = AppDomain.CreateDomain ("ApplyPolicy_Empty");
1241 ad.ApplyPolicy (String.Empty);
1245 [ExpectedException (typeof (ArgumentNullException))]
1246 public void ApplyPolicy_Null ()
1248 ad = AppDomain.CreateDomain ("ApplyPolicy_Null");
1249 ad.ApplyPolicy (null);
1253 public void DomainManager ()
1255 Assert.IsNull (AppDomain.CurrentDomain.DomainManager, "CurrentDomain.DomainManager");
1256 ad = AppDomain.CreateDomain ("DomainManager");
1257 Assert.IsNull (ad.DomainManager, "ad.DomainManager");
1261 public void IsDefaultAppDomain ()
1263 ad = AppDomain.CreateDomain ("ReflectionOnlyGetAssemblies");
1264 Assert.IsFalse (ad.IsDefaultAppDomain (), "IsDefaultAppDomain");
1265 // we have no public way to get the default appdomain
1269 public void ReflectionOnlyGetAssemblies ()
1271 ad = AppDomain.CreateDomain ("ReflectionOnlyGetAssemblies");
1272 Assembly [] a = ad.ReflectionOnlyGetAssemblies ();
1273 Assert.IsNotNull (a, "ReflectionOnlyGetAssemblies");
1274 Assert.AreEqual (0, a.Length, "Count");
1278 private static AppDomain CreateTestDomain (string baseDirectory, bool assemblyResolver)
1280 AppDomainSetup setup = new AppDomainSetup ();
1281 setup.ApplicationBase = baseDirectory;
1282 setup.ApplicationName = "testdomain";
1284 AppDomain ad = AppDomain.CreateDomain ("testdomain",
1285 AppDomain.CurrentDomain.Evidence, setup);
1287 if (assemblyResolver) {
1288 Assembly ea = Assembly.GetExecutingAssembly ();
1289 ad.CreateInstanceFrom (ea.CodeBase,
1290 typeof (AssemblyResolveHandler).FullName,
1292 BindingFlags.Public | BindingFlags.Instance,
1294 new object [] { ea.Location, ea.FullName },
1295 CultureInfo.InvariantCulture,
1303 private static CrossDomainTester CreateCrossDomainTester (AppDomain domain)
1305 Type testerType = typeof (CrossDomainTester);
1306 return (CrossDomainTester) domain.CreateInstanceAndUnwrap (
1307 testerType.Assembly.FullName, testerType.FullName, false,
1308 BindingFlags.Public | BindingFlags.Instance, null, new object [0],
1309 CultureInfo.InvariantCulture, new object [0], null);
1312 private static void GenerateAssembly (AssemblyName aname, string path)
1314 AppDomain ad = CreateTestDomain (AppDomain.CurrentDomain.BaseDirectory,
1317 CrossDomainTester cdt = CreateCrossDomainTester (ad);
1318 cdt.GenerateAssembly (aname, path);
1320 AppDomain.Unload (ad);
1324 private class CrossDomainTester : MarshalByRefObject
1326 public void GenerateAssembly (AssemblyName aname, string path)
1328 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1329 aname, AssemblyBuilderAccess.Save, Path.GetDirectoryName (path));
1330 ab.Save (Path.GetFileName (path));
1333 public int AssemblyCount {
1335 return AppDomain.CurrentDomain.GetAssemblies ().Length;
1339 public void Load (AssemblyName assemblyRef)
1341 AppDomain.CurrentDomain.Load (assemblyRef);
1344 public void LoadFrom (string assemblyFile)
1346 Assembly.LoadFrom (assemblyFile);
1349 public bool AssertLoad (AssemblyName assemblyRef)
1352 AppDomain.CurrentDomain.Load (assemblyRef);
1359 public bool AssertLoad (string assemblyString)
1362 AppDomain.CurrentDomain.Load (assemblyString);
1369 public bool AssertFileLoadException (AssemblyName assemblyRef)
1372 AppDomain.CurrentDomain.Load (assemblyRef);
1374 } catch (FileLoadException) {
1379 public bool AssertFileNotFoundException (AssemblyName assemblyRef)
1382 AppDomain.CurrentDomain.Load (assemblyRef);
1384 } catch (FileNotFoundException) {
1391 private class AssemblyResolveHandler
1393 public AssemblyResolveHandler (string assemblyFile, string assemblyName)
1395 _assemblyFile = assemblyFile;
1396 _assemblyName = assemblyName;
1398 AppDomain.CurrentDomain.AssemblyResolve +=
1399 new ResolveEventHandler (ResolveAssembly);
1402 private Assembly ResolveAssembly (Object sender, ResolveEventArgs args)
1404 if (args.Name == _assemblyName)
1405 return Assembly.LoadFrom (_assemblyFile);
1410 private readonly string _assemblyFile;
1411 private readonly string _assemblyName;
1414 static byte [] keyPair = {
1415 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41,
1416 0x32, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x3D, 0xBD,
1417 0x72, 0x08, 0xC6, 0x2B, 0x0E, 0xA8, 0xC1, 0xC0, 0x58, 0x07, 0x2B,
1418 0x63, 0x5F, 0x7C, 0x9A, 0xBD, 0xCB, 0x22, 0xDB, 0x20, 0xB2, 0xA9,
1419 0xDA, 0xDA, 0xEF, 0xE8, 0x00, 0x64, 0x2F, 0x5D, 0x8D, 0xEB, 0x78,
1420 0x02, 0xF7, 0xA5, 0x36, 0x77, 0x28, 0xD7, 0x55, 0x8D, 0x14, 0x68,
1421 0xDB, 0xEB, 0x24, 0x09, 0xD0, 0x2B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0x4E,
1471 static byte [] publicKey2 = {
1472 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41,
1473 0x32, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7F, 0x7C,
1474 0xEA, 0x4A, 0x28, 0x33, 0xD8, 0x3C, 0x86, 0x90, 0x86, 0x91, 0x11,
1475 0xBB, 0x30, 0x0D, 0x3D, 0x69, 0x04, 0x4C, 0x48, 0xF5, 0x4F, 0xE7,
1476 0x64, 0xA5, 0x82, 0x72, 0x5A, 0x92, 0xC4, 0x3D, 0xC5, 0x90, 0x93,
1477 0x41, 0xC9, 0x1D, 0x34, 0x16, 0x72, 0x2B, 0x85, 0xC1, 0xF3, 0x99,
1478 0x62, 0x07, 0x32, 0x98, 0xB7, 0xE4, 0xFA, 0x75, 0x81, 0x8D, 0x08,
1479 0xB9, 0xFD, 0xDB, 0x00, 0x25, 0x30, 0xC4, 0x89, 0x13, 0xB6, 0x43,
1480 0xE8, 0xCC, 0xBE, 0x03, 0x2E, 0x1A, 0x6A, 0x4D, 0x36, 0xB1, 0xEB,
1481 0x49, 0x26, 0x6C, 0xAB, 0xC4, 0x29, 0xD7, 0x8F, 0x25, 0x11, 0xA4,
1482 0x7C, 0x81, 0x61, 0x97, 0xCB, 0x44, 0x2D, 0x80, 0x49, 0x93, 0x48,
1483 0xA7, 0xC9, 0xAB, 0xDB, 0xCF, 0xA3, 0x34, 0xCB, 0x6B, 0x86, 0xE0,
1484 0x4D, 0x27, 0xFC, 0xA7, 0x4F, 0x36, 0xCA, 0x13, 0x42, 0xD3, 0x83,
1485 0xC4, 0x06, 0x6E, 0x12, 0xE0, 0xA1, 0x3D, 0x9F, 0xA9, 0xEC, 0xD1,
1486 0xC6, 0x08, 0x1B, 0x3D, 0xF5, 0xDB, 0x4C, 0xD4, 0xF0, 0x2C, 0xAA,
1487 0xFC, 0xBA, 0x18, 0x6F, 0x48, 0x7E, 0xB9, 0x47, 0x68, 0x2E, 0xF6,
1488 0x1E, 0x67, 0x1C, 0x7E, 0x0A, 0xCE, 0x10, 0x07, 0xC0, 0x0C, 0xAD,
1489 0x5E, 0xC1, 0x53, 0x70, 0xD5, 0xE7, 0x25, 0xCA, 0x37, 0x5E, 0x49,
1490 0x59, 0xD0, 0x67, 0x2A, 0xBE, 0x92, 0x36, 0x86, 0x8A, 0xBF, 0x3E,
1491 0x17, 0x04, 0xFB, 0x1F, 0x46, 0xC8, 0x10, 0x5C, 0x93, 0x02, 0x43,
1492 0x14, 0x96, 0x6A, 0xD9, 0x87, 0x17, 0x62, 0x7D, 0x3A, 0x45, 0xBE,
1493 0x35, 0xDE, 0x75, 0x0B, 0x2A, 0xCE, 0x7D, 0xF3, 0x19, 0x85, 0x4B,
1494 0x0D, 0x6F, 0x8D, 0x15, 0xA3, 0x60, 0x61, 0x28, 0x55, 0x46, 0xCE,
1495 0x78, 0x31, 0x04, 0x18, 0x3C, 0x56, 0x4A, 0x3F, 0xA4, 0xC9, 0xB1,
1496 0x41, 0xED, 0x22, 0x80, 0xA1, 0xB3, 0xE2, 0xC7, 0x1B, 0x62, 0x85,
1497 0xE4, 0x81, 0x39, 0xCB, 0x1F, 0x95, 0xCC, 0x61, 0x61, 0xDF, 0xDE,
1498 0xF3, 0x05, 0x68, 0xB9, 0x7D, 0x4F, 0xFF, 0xF3, 0xC0, 0x0A, 0x25,
1499 0x62, 0xD9, 0x8A, 0x8A, 0x9E, 0x99, 0x0B, 0xFB, 0x85, 0x27, 0x8D,
1500 0xF6, 0xD4, 0xE1, 0xB9, 0xDE, 0xB4, 0x16, 0xBD, 0xDF, 0x6A, 0x25,
1501 0x9C, 0xAC, 0xCD, 0x91, 0xF7, 0xCB, 0xC1, 0x81, 0x22, 0x0D, 0xF4,
1502 0x7E, 0xEC, 0x0C, 0x84, 0x13, 0x5A, 0x74, 0x59, 0x3F, 0x3E, 0x61,
1503 0x00, 0xD6, 0xB5, 0x4A, 0xA1, 0x04, 0xB5, 0xA7, 0x1C, 0x29, 0xD0,
1504 0xE1, 0x11, 0x19, 0xD7, 0x80, 0x5C, 0xEE, 0x08, 0x15, 0xEB, 0xC9,
1505 0xA8, 0x98, 0xF5, 0xA0, 0xF0, 0x92, 0x2A, 0xB0, 0xD3, 0xC7, 0x8C,
1506 0x8D, 0xBB, 0x88, 0x96, 0x4F, 0x18, 0xF0, 0x8A, 0xF9, 0x31, 0x9E,
1507 0x44, 0x94, 0x75, 0x6F, 0x78, 0x04, 0x10, 0xEC, 0xF3, 0xB0, 0xCE,
1508 0xA0, 0xBE, 0x7B, 0x25, 0xE1, 0xF7, 0x8A, 0xA8, 0xD4, 0x63, 0xC2,
1509 0x65, 0x47, 0xCC, 0x5C, 0xED, 0x7D, 0x8B, 0x07, 0x4D, 0x76, 0x29,
1510 0x53, 0xAC, 0x27, 0x8F, 0x5D, 0x78, 0x56, 0xFA, 0x99, 0x45, 0xA2,
1511 0xCC, 0x65, 0xC4, 0x54, 0x13, 0x9F, 0x38, 0x41, 0x7A, 0x61, 0x0E,
1512 0x0D, 0x34, 0xBC, 0x11, 0xAF, 0xE2, 0xF1, 0x8B, 0xFA, 0x2B, 0x54,
1513 0x6C, 0xA3, 0x6C, 0x09, 0x1F, 0x0B, 0x43, 0x9B, 0x07, 0x95, 0x83,
1514 0x3F, 0x97, 0x99, 0x89, 0xF5, 0x51, 0x41, 0xF6, 0x8E, 0x5D, 0xEF,
1515 0x6D, 0x24, 0x71, 0x41, 0x7A, 0xAF, 0xBE, 0x81, 0x71, 0xAB, 0x76,
1516 0x2F, 0x1A, 0x5A, 0xBA, 0xF3, 0xA6, 0x65, 0x7A, 0x80, 0x50, 0xCE,
1517 0x23, 0xC3, 0xC7, 0x53, 0xB0, 0x7C, 0x97, 0x77, 0x27, 0x70, 0x98,
1518 0xAE, 0xB5, 0x24, 0x66, 0xE1, 0x60, 0x39, 0x41, 0xDA, 0x54, 0x01,
1519 0x64, 0xFB, 0x10, 0x33, 0xCE, 0x8B, 0xBE, 0x27, 0xD4, 0x21, 0x57,
1520 0xCC, 0x0F, 0x1A, 0xC1, 0x3D, 0xF3, 0xCC, 0x39, 0xF0, 0x2F, 0xAE,
1521 0xF1, 0xC0, 0xCD, 0x3B, 0x23, 0x87, 0x49, 0x7E, 0x40, 0x32, 0x6A,
1522 0xD3, 0x96, 0x4A, 0xE5, 0x5E, 0x6E, 0x26, 0xFD, 0x8A, 0xCF, 0x7E,
1523 0xFC, 0x37, 0xDE, 0x39, 0x0C, 0x53, 0x81, 0x75, 0x08, 0xAF, 0x6B,
1524 0x39, 0x6C, 0xFB, 0xC9, 0x79, 0xC0, 0x9B, 0x5F, 0x34, 0x86, 0xB2,
1525 0xDE, 0xC4, 0x19, 0x84, 0x5F, 0x0E, 0xED, 0x9B, 0xB8, 0xD3, 0x17,
1528 static byte [] publicKey = {
1529 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00,
1530 0x00, 0x06, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53,
1531 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x3d,
1532 0xbd, 0x72, 0x08, 0xc6, 0x2b, 0x0e, 0xa8, 0xc1, 0xc0, 0x58, 0x07,
1533 0x2b, 0x63, 0x5f, 0x7c, 0x9a, 0xbd, 0xcb, 0x22, 0xdb, 0x20, 0xb2,
1534 0xa9, 0xda, 0xda, 0xef, 0xe8, 0x00, 0x64, 0x2f, 0x5d, 0x8d, 0xeb,
1535 0x78, 0x02, 0xf7, 0xa5, 0x36, 0x77, 0x28, 0xd7, 0x55, 0x8d, 0x14,
1536 0x68, 0xdb, 0xeb, 0x24, 0x09, 0xd0, 0x2b, 0x13, 0x1b, 0x92, 0x6e,
1537 0x2e, 0x59, 0x54, 0x4a, 0xac, 0x18, 0xcf, 0xc9, 0x09, 0x02, 0x3f,
1538 0x4f, 0xa8, 0x3e, 0x94, 0x00, 0x1f, 0xc2, 0xf1, 0x1a, 0x27, 0x47,
1539 0x7d, 0x10, 0x84, 0xf5, 0x14, 0xb8, 0x61, 0x62, 0x1a, 0x0c, 0x66,
1540 0xab, 0xd2, 0x4c, 0x4b, 0x9f, 0xc9, 0x0f, 0x3c, 0xd8, 0x92, 0x0f,
1541 0xf5, 0xff, 0xce, 0xd7, 0x6e, 0x5c, 0x6f, 0xb1, 0xf5, 0x7d, 0xd3,
1542 0x56, 0xf9, 0x67, 0x27, 0xa4, 0xa5, 0x48, 0x5b, 0x07, 0x93, 0x44,
1543 0x00, 0x4a, 0xf8, 0xff, 0xa4, 0xcb };