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.Collections.Generic;
33 using System.Configuration.Assemblies;
34 using System.Globalization;
36 using System.Reflection;
37 using System.Reflection.Emit;
38 using System.Runtime.InteropServices;
39 using System.Security;
40 using System.Security.Permissions;
41 using System.Security.Policy;
42 using System.Security.Principal;
44 namespace MonoTests.System
47 public class AppDomainTest
50 private ArrayList files = new ArrayList ();
51 private string tempDir;
56 tempDir = Path.Combine (Path.GetTempPath (), Environment.UserName);
57 tempDir = Path.Combine (tempDir, "MonoTests.System.AppDomainTest");
58 if (!Directory.Exists (tempDir)) {
59 Directory.CreateDirectory (tempDir);
64 public void TearDown ()
68 AppDomain.Unload (ad);
70 } catch { } // do not affect unit test results in TearDown
72 foreach (string fname in files) {
79 public void ConfigurationFile_Relative ()
82 // We use Environment.GetCommandLineArgs () to get the location of
83 // the entry assembly in the default domain (since the default domain
84 // is not exposed by any API)
86 // MS returns a lower-case path in Environment.GetCommandLineArgs ()
87 // and hence we need to perform a case-insensitive comparison
88 // if the Assert involves that path
90 string configFile = "test.config";
91 string appBase = null;
92 string expectedConfigFile = null;
93 string expectedAppBase = null;
95 // do not set ApplicationBase
96 appBase = Path.GetDirectoryName (Environment.GetCommandLineArgs () [0]);
97 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
98 appBase : appBase + Path.DirectorySeparatorChar;
99 expectedConfigFile = Path.Combine (appBase, configFile);
100 AppDomainSetup setup = new AppDomainSetup();
101 setup.ConfigurationFile = configFile;
102 ad = CreateTestDomain (setup, true);
103 CrossDomainTester cdt = CreateCrossDomainTester (ad);
105 Assert.AreEqual (expectedConfigFile, cdt.GetConfigurationFile (), "#A1");
106 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#A2");
108 Assert.IsTrue (string.Compare (expectedConfigFile, cdt.GetConfigurationFile (), true) == 0, "#A1");
109 Assert.IsTrue (string.Compare (expectedAppBase, cdt.GetApplicationBase (), true) == 0, "#A2");
111 AppDomain.Unload (ad);
113 // set ApplicationBase
114 appBase = Path.GetTempPath ();
115 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
116 appBase : appBase + Path.DirectorySeparatorChar;
117 expectedConfigFile = Path.Combine (appBase, configFile);
118 setup = new AppDomainSetup ();
119 setup.ApplicationBase = appBase;
120 setup.ConfigurationFile = configFile;
121 ad = CreateTestDomain (setup, true);
122 cdt = CreateCrossDomainTester (ad);
123 Assert.AreEqual (expectedConfigFile, cdt.GetConfigurationFile (), "#B1");
124 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#B2");
125 AppDomain.Unload (ad);
129 public void ConfigurationFile_Absolute ()
132 // We use Environment.GetCommandLineArgs () to get the location of
133 // the entry assembly in the default domain (since the default domain
134 // is not exposed by any API)
136 // MS returns a lower-case path in Environment.GetCommandLineArgs ()
137 // and hence on Windows we need to perform a case-insensitive
138 // comparison if the Assert involves that path
140 string configFile = Path.Combine (tempDir, "test.config");
141 string appBase = null;
142 string expectedAppBase = null;
144 // do not set ApplicationBase
145 appBase = Path.GetDirectoryName (Environment.GetCommandLineArgs () [0]);
146 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
147 appBase : appBase + Path.DirectorySeparatorChar;
148 AppDomainSetup setup = new AppDomainSetup ();
149 setup.ConfigurationFile = configFile;
150 ad = CreateTestDomain (setup, true);
151 CrossDomainTester cdt = CreateCrossDomainTester (ad);
152 Assert.AreEqual (configFile, cdt.GetConfigurationFile (), "#A1");
154 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#A2");
156 Assert.IsTrue (string.Compare (expectedAppBase, cdt.GetApplicationBase (), true) == 0, "#A2");
158 AppDomain.Unload (ad);
160 // set ApplicationBase
161 appBase = Path.GetTempPath ();
162 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
163 appBase : appBase + Path.DirectorySeparatorChar;
164 setup = new AppDomainSetup ();
165 setup.ApplicationBase = appBase;
166 setup.ConfigurationFile = configFile;
167 ad = CreateTestDomain (setup, true);
168 cdt = CreateCrossDomainTester (ad);
169 Assert.AreEqual (configFile, cdt.GetConfigurationFile (), "#B1");
170 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#B2");
171 AppDomain.Unload (ad);
175 public void ConfigurationFile_Null ()
178 // We use Environment.GetCommandLineArgs () to get the location of
179 // the entry assembly in the default domain (since the default domain
180 // is not exposed by any API)
182 // MS returns a lower-case path in Environment.GetCommandLineArgs ()
183 // and hence we need to perform a case-insensitive comparison
184 // if the Assert involves that path
186 string appBase = null;
187 string expectedAppBase = null;
188 string expectedConfigFile = null;
190 // do not set ApplicationBase
191 appBase = Path.GetDirectoryName (Environment.GetCommandLineArgs () [0]);
192 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
193 appBase : appBase + Path.DirectorySeparatorChar;
194 expectedConfigFile = Environment.GetCommandLineArgs () [0] + ".config";
195 AppDomainSetup setup = new AppDomainSetup ();
196 setup.ConfigurationFile = null;
197 ad = CreateTestDomain (setup, true);
198 CrossDomainTester cdt = CreateCrossDomainTester (ad);
200 Assert.AreEqual (expectedConfigFile, cdt.GetConfigurationFile (), "#A1");
201 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#A2");
203 Assert.IsTrue (string.Compare (expectedConfigFile, cdt.GetConfigurationFile (), true) == 0, "#A1");
204 Assert.IsTrue (string.Compare (expectedAppBase, cdt.GetApplicationBase (), true) == 0, "#A2");
206 AppDomain.Unload (ad);
208 // set ApplicationBase
209 appBase = Path.GetTempPath ();
210 expectedAppBase = appBase [appBase.Length - 1] == Path.DirectorySeparatorChar ?
211 appBase : appBase + Path.DirectorySeparatorChar;
212 expectedConfigFile = Path.Combine (appBase, Path.GetFileName (Environment.GetCommandLineArgs () [0]) + ".config");
213 setup = new AppDomainSetup ();
214 setup.ApplicationBase = appBase;
215 setup.ConfigurationFile = null;
216 ad = CreateTestDomain (setup, true);
217 cdt = CreateCrossDomainTester (ad);
219 Assert.AreEqual (expectedConfigFile, cdt.GetConfigurationFile (), "#B1");
221 Assert.IsTrue (string.Compare (expectedConfigFile, cdt.GetConfigurationFile (), true) == 0, "#B1");
223 Assert.AreEqual (expectedAppBase, cdt.GetApplicationBase (), "#B2");
224 AppDomain.Unload (ad);
227 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess)
228 public void DefineDynamicAssembly1_Access_Invalid ()
230 AssemblyName name = new AssemblyName ();
231 name.Name = "DefineDynamicAssembly1";
234 AppDomain.CurrentDomain.DefineDynamicAssembly (
235 name, AssemblyBuilderAccess.Run |
236 (AssemblyBuilderAccess) 666);
238 } catch (ArgumentException ex) {
239 // Illegal enum value: 667
240 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
241 Assert.IsNull (ex.InnerException, "#3");
242 Assert.IsNotNull (ex.Message, "#4");
243 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
244 Assert.IsNotNull (ex.ParamName, "#6");
245 Assert.AreEqual ("access", ex.ParamName, "#7");
249 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess)
250 public void DefineDynamicAssembly1_Name_InvalidChars ()
252 string [] invalid_char_names = new string [] {
262 AssemblyName name = new AssemblyName ();
264 foreach (string invalid_name in invalid_char_names) {
265 name.Name = invalid_name;
267 AppDomain.CurrentDomain.DefineDynamicAssembly (
269 AssemblyBuilderAccess.Run);
270 Assert.Fail ("#1:" + invalid_name);
271 } catch (ArgumentException ex) {
272 // Assembly names may not begin with whitespace
273 // or contain the characters '/', '\' or ':'
274 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
275 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
276 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
277 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
278 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
279 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
280 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
285 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess)
286 public void DefineDynamicAssembly1_Name_Null ()
289 AppDomain.CurrentDomain.DefineDynamicAssembly (
291 AssemblyBuilderAccess.Run);
293 } catch (ArgumentNullException ex) {
294 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
295 Assert.IsNull (ex.InnerException, "#A3");
296 Assert.IsNotNull (ex.Message, "#A4");
297 Assert.IsNotNull (ex.ParamName, "#A5");
298 Assert.AreEqual ("name", ex.ParamName, "#A6");
301 AssemblyName name = new AssemblyName ();
304 AppDomain.CurrentDomain.DefineDynamicAssembly (
306 AssemblyBuilderAccess.Run);
308 } catch (ArgumentException ex) {
309 // AssemblyName.Name cannot be null or an empty string
310 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
311 Assert.IsNull (ex.InnerException, "#B3");
312 Assert.IsNotNull (ex.Message, "#B4");
313 Assert.IsNull (ex.ParamName, "#B5");
316 name.Name = string.Empty;
319 AppDomain.CurrentDomain.DefineDynamicAssembly (
321 AssemblyBuilderAccess.Run);
323 } catch (ArgumentException ex) {
324 // AssemblyName.Name cannot be null or an empty string
325 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
326 Assert.IsNull (ex.InnerException, "#C3");
327 Assert.IsNotNull (ex.Message, "#C4");
328 Assert.IsNull (ex.ParamName, "#C5");
332 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence)
333 public void DefineDynamicAssembly2_Access_Invalid ()
335 AssemblyName name = new AssemblyName ();
336 name.Name = "DefineDynamicAssembly2";
340 AppDomain.CurrentDomain.DefineDynamicAssembly (
341 name, AssemblyBuilderAccess.Run |
342 (AssemblyBuilderAccess) 666,
343 AppDomain.CurrentDomain.Evidence);
345 } catch (ArgumentException ex) {
346 // Illegal enum value: 667
347 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
348 Assert.IsNull (ex.InnerException, "#3");
349 Assert.IsNotNull (ex.Message, "#4");
350 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
351 Assert.IsNotNull (ex.ParamName, "#6");
352 Assert.AreEqual ("access", ex.ParamName, "#7");
355 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
356 name, AssemblyBuilderAccess.Run |
357 (AssemblyBuilderAccess) 666,
358 AppDomain.CurrentDomain.Evidence);
359 Assert.IsNotNull (ab, "#1");
363 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence)
364 public void DefineDynamicAssembly2_Name_InvalidChars ()
366 string [] invalid_char_names = new string [] {
376 AssemblyName name = new AssemblyName ();
378 foreach (string invalid_name in invalid_char_names) {
379 name.Name = invalid_name;
381 AppDomain.CurrentDomain.DefineDynamicAssembly (
383 AssemblyBuilderAccess.Run,
384 AppDomain.CurrentDomain.Evidence);
385 Assert.Fail ("#1:" + invalid_name);
386 } catch (ArgumentException ex) {
387 // Assembly names may not begin with whitespace
388 // or contain the characters '/', '\' or ':'
389 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
390 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
391 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
392 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
393 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
394 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
395 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
400 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence)
401 public void DefineDynamicAssembly2_Name_Null ()
404 AppDomain.CurrentDomain.DefineDynamicAssembly (
406 AssemblyBuilderAccess.Run,
407 AppDomain.CurrentDomain.Evidence);
409 } catch (ArgumentNullException ex) {
410 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
411 Assert.IsNull (ex.InnerException, "#A3");
412 Assert.IsNotNull (ex.Message, "#A4");
413 Assert.IsNotNull (ex.ParamName, "#A5");
414 Assert.AreEqual ("name", ex.ParamName, "#A6");
417 AssemblyName name = new AssemblyName ();
420 AppDomain.CurrentDomain.DefineDynamicAssembly (
422 AssemblyBuilderAccess.Run,
423 AppDomain.CurrentDomain.Evidence);
425 } catch (ArgumentException ex) {
426 // AssemblyName.Name cannot be null or an empty string
427 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
428 Assert.IsNull (ex.InnerException, "#B3");
429 Assert.IsNotNull (ex.Message, "#B4");
430 Assert.IsNull (ex.ParamName, "#B5");
433 name.Name = string.Empty;
436 AppDomain.CurrentDomain.DefineDynamicAssembly (
438 AssemblyBuilderAccess.Run,
439 AppDomain.CurrentDomain.Evidence);
441 } catch (ArgumentException ex) {
442 // AssemblyName.Name cannot be null or an empty string
443 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
444 Assert.IsNull (ex.InnerException, "#C3");
445 Assert.IsNotNull (ex.Message, "#C4");
446 Assert.IsNull (ex.ParamName, "#C5");
450 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String)
451 public void DefineDynamicAssembly3_Access_Invalid ()
453 AssemblyName name = new AssemblyName ();
454 name.Name = "DefineDynamicAssembly3";
458 AppDomain.CurrentDomain.DefineDynamicAssembly (
459 name, AssemblyBuilderAccess.Run |
460 (AssemblyBuilderAccess) 666,
461 Path.GetTempPath ());
463 } catch (ArgumentException ex) {
464 // Illegal enum value: 667
465 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
466 Assert.IsNull (ex.InnerException, "#3");
467 Assert.IsNotNull (ex.Message, "#4");
468 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
469 Assert.IsNotNull (ex.ParamName, "#6");
470 Assert.AreEqual ("access", ex.ParamName, "#7");
473 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
474 name, AssemblyBuilderAccess.Run |
475 (AssemblyBuilderAccess) 666,
476 Path.GetTempPath ());
477 Assert.IsNotNull (ab, "#1");
481 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String)
482 public void DefineDynamicAssembly3_Name_InvalidChars ()
484 string [] invalid_char_names = new string [] {
494 AssemblyName name = new AssemblyName ();
496 foreach (string invalid_name in invalid_char_names) {
497 name.Name = invalid_name;
499 AppDomain.CurrentDomain.DefineDynamicAssembly (
501 AssemblyBuilderAccess.Run,
502 Path.GetTempPath ());
503 Assert.Fail ("#1:" + invalid_name);
504 } catch (ArgumentException ex) {
505 // Assembly names may not begin with whitespace
506 // or contain the characters '/', '\' or ':'
507 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
508 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
509 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
510 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
511 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
512 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
513 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
518 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String)
519 public void DefineDynamicAssembly3_Name_Null ()
522 AppDomain.CurrentDomain.DefineDynamicAssembly (
524 AssemblyBuilderAccess.Run,
525 Path.GetTempPath ());
527 } catch (ArgumentNullException ex) {
528 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
529 Assert.IsNull (ex.InnerException, "#A3");
530 Assert.IsNotNull (ex.Message, "#A4");
531 Assert.IsNotNull (ex.ParamName, "#A5");
532 Assert.AreEqual ("name", ex.ParamName, "#A6");
535 AssemblyName name = new AssemblyName ();
538 AppDomain.CurrentDomain.DefineDynamicAssembly (
540 AssemblyBuilderAccess.Run,
541 Path.GetTempPath ());
543 } catch (ArgumentException ex) {
544 // AssemblyName.Name cannot be null or an empty string
545 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
546 Assert.IsNull (ex.InnerException, "#B3");
547 Assert.IsNotNull (ex.Message, "#B4");
548 Assert.IsNull (ex.ParamName, "#B5");
551 name.Name = string.Empty;
554 AppDomain.CurrentDomain.DefineDynamicAssembly (
556 AssemblyBuilderAccess.Run,
557 Path.GetTempPath ());
559 } catch (ArgumentException ex) {
560 // AssemblyName.Name cannot be null or an empty string
561 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
562 Assert.IsNull (ex.InnerException, "#C3");
563 Assert.IsNotNull (ex.Message, "#C4");
564 Assert.IsNull (ex.ParamName, "#C5");
568 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence)
569 public void DefineDynamicAssembly4_Access_Invalid ()
571 AssemblyName name = new AssemblyName ();
572 name.Name = "DefineDynamicAssembly4";
576 AppDomain.CurrentDomain.DefineDynamicAssembly (
577 name, AssemblyBuilderAccess.Run |
578 (AssemblyBuilderAccess) 666,
580 AppDomain.CurrentDomain.Evidence);
582 } catch (ArgumentException ex) {
583 // Illegal enum value: 667
584 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
585 Assert.IsNull (ex.InnerException, "#3");
586 Assert.IsNotNull (ex.Message, "#4");
587 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
588 Assert.IsNotNull (ex.ParamName, "#6");
589 Assert.AreEqual ("access", ex.ParamName, "#7");
592 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
593 name, AssemblyBuilderAccess.Run |
594 (AssemblyBuilderAccess) 666,
596 AppDomain.CurrentDomain.Evidence);
597 Assert.IsNotNull (ab, "#1");
601 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence)
602 public void DefineDynamicAssembly4_Name_InvalidChars ()
604 string [] invalid_char_names = new string [] {
614 AssemblyName name = new AssemblyName ();
616 foreach (string invalid_name in invalid_char_names) {
617 name.Name = invalid_name;
619 AppDomain.CurrentDomain.DefineDynamicAssembly (
621 AssemblyBuilderAccess.Run,
623 AppDomain.CurrentDomain.Evidence);
624 Assert.Fail ("#1:" + invalid_name);
625 } catch (ArgumentException ex) {
626 // Assembly names may not begin with whitespace
627 // or contain the characters '/', '\' or ':'
628 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
629 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
630 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
631 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
632 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
633 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
634 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
639 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence)
640 public void DefineDynamicAssembly4_Name_Null ()
643 AppDomain.CurrentDomain.DefineDynamicAssembly (
645 AssemblyBuilderAccess.Run,
647 AppDomain.CurrentDomain.Evidence);
649 } catch (ArgumentNullException ex) {
650 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
651 Assert.IsNull (ex.InnerException, "#A3");
652 Assert.IsNotNull (ex.Message, "#A4");
653 Assert.IsNotNull (ex.ParamName, "#A5");
654 Assert.AreEqual ("name", ex.ParamName, "#A6");
657 AssemblyName name = new AssemblyName ();
660 AppDomain.CurrentDomain.DefineDynamicAssembly (
662 AssemblyBuilderAccess.Run,
664 AppDomain.CurrentDomain.Evidence);
666 } catch (ArgumentException ex) {
667 // AssemblyName.Name cannot be null or an empty string
668 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
669 Assert.IsNull (ex.InnerException, "#B3");
670 Assert.IsNotNull (ex.Message, "#B4");
671 Assert.IsNull (ex.ParamName, "#B5");
674 name.Name = string.Empty;
677 AppDomain.CurrentDomain.DefineDynamicAssembly (
679 AssemblyBuilderAccess.Run,
681 AppDomain.CurrentDomain.Evidence);
683 } catch (ArgumentException ex) {
684 // AssemblyName.Name cannot be null or an empty string
685 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
686 Assert.IsNull (ex.InnerException, "#C3");
687 Assert.IsNotNull (ex.Message, "#C4");
688 Assert.IsNull (ex.ParamName, "#C5");
692 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, PermissionSet, PermissionSet, PermissionSet)
693 public void DefineDynamicAssembly5_Access_Invalid ()
695 AssemblyName name = new AssemblyName ();
696 name.Name = "DefineDynamicAssembly5";
700 AppDomain.CurrentDomain.DefineDynamicAssembly (
701 name, AssemblyBuilderAccess.Run |
702 (AssemblyBuilderAccess) 666,
703 (PermissionSet) null,
704 (PermissionSet) null,
705 (PermissionSet) null);
707 } catch (ArgumentException ex) {
708 // Illegal enum value: 667
709 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
710 Assert.IsNull (ex.InnerException, "#3");
711 Assert.IsNotNull (ex.Message, "#4");
712 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
713 Assert.IsNotNull (ex.ParamName, "#6");
714 Assert.AreEqual ("access", ex.ParamName, "#7");
717 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
718 name, AssemblyBuilderAccess.Run |
719 (AssemblyBuilderAccess) 666,
720 (PermissionSet) null,
721 (PermissionSet) null,
722 (PermissionSet) null);
723 Assert.IsNotNull (ab, "#1");
727 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, PermissionSet, PermissionSet, PermissionSet)
728 public void DefineDynamicAssembly5_Name_InvalidChars ()
730 string [] invalid_char_names = new string [] {
740 AssemblyName name = new AssemblyName ();
742 foreach (string invalid_name in invalid_char_names) {
743 name.Name = invalid_name;
745 AppDomain.CurrentDomain.DefineDynamicAssembly (
747 AssemblyBuilderAccess.Run,
748 (PermissionSet) null,
749 (PermissionSet) null,
750 (PermissionSet) null);
751 Assert.Fail ("#1:" + invalid_name);
752 } catch (ArgumentException ex) {
753 // Assembly names may not begin with whitespace
754 // or contain the characters '/', '\' or ':'
755 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
756 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
757 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
758 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
759 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
760 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
761 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
766 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, PermissionSet, PermissionSet, PermissionSet)
767 public void DefineDynamicAssembly5_Name_Null ()
770 AppDomain.CurrentDomain.DefineDynamicAssembly (
772 AssemblyBuilderAccess.Run,
773 (PermissionSet) null,
774 (PermissionSet) null,
775 (PermissionSet) null);
777 } catch (ArgumentNullException ex) {
778 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
779 Assert.IsNull (ex.InnerException, "#A3");
780 Assert.IsNotNull (ex.Message, "#A4");
781 Assert.IsNotNull (ex.ParamName, "#A5");
782 Assert.AreEqual ("name", ex.ParamName, "#A6");
785 AssemblyName name = new AssemblyName ();
788 AppDomain.CurrentDomain.DefineDynamicAssembly (
790 AssemblyBuilderAccess.Run,
791 (PermissionSet) null,
792 (PermissionSet) null,
793 (PermissionSet) null);
795 } catch (ArgumentException ex) {
796 // AssemblyName.Name cannot be null or an empty string
797 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
798 Assert.IsNull (ex.InnerException, "#B3");
799 Assert.IsNotNull (ex.Message, "#B4");
800 Assert.IsNull (ex.ParamName, "#B5");
803 name.Name = string.Empty;
806 AppDomain.CurrentDomain.DefineDynamicAssembly (
808 AssemblyBuilderAccess.Run,
809 (PermissionSet) null,
810 (PermissionSet) null,
811 (PermissionSet) null);
813 } catch (ArgumentException ex) {
814 // AssemblyName.Name cannot be null or an empty string
815 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
816 Assert.IsNull (ex.InnerException, "#C3");
817 Assert.IsNotNull (ex.Message, "#C4");
818 Assert.IsNull (ex.ParamName, "#C5");
822 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence, PermissionSet, PermissionSet, PermissionSet)
823 public void DefineDynamicAssembly6_Access_Invalid ()
825 AssemblyName name = new AssemblyName ();
826 name.Name = "DefineDynamicAssembly6";
830 AppDomain.CurrentDomain.DefineDynamicAssembly (
831 name, AssemblyBuilderAccess.Run |
832 (AssemblyBuilderAccess) 666,
833 AppDomain.CurrentDomain.Evidence,
834 (PermissionSet) null,
835 (PermissionSet) null,
836 (PermissionSet) null);
838 } catch (ArgumentException ex) {
839 // Illegal enum value: 667
840 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
841 Assert.IsNull (ex.InnerException, "#3");
842 Assert.IsNotNull (ex.Message, "#4");
843 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
844 Assert.IsNotNull (ex.ParamName, "#6");
845 Assert.AreEqual ("access", ex.ParamName, "#7");
848 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
849 name, AssemblyBuilderAccess.Run |
850 (AssemblyBuilderAccess) 666,
851 AppDomain.CurrentDomain.Evidence,
852 (PermissionSet) null,
853 (PermissionSet) null,
854 (PermissionSet) null);
855 Assert.IsNotNull (ab, "#1");
859 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence, PermissionSet, PermissionSet, PermissionSet)
860 public void DefineDynamicAssembly6_Name_InvalidChars ()
862 string [] invalid_char_names = new string [] {
872 AssemblyName name = new AssemblyName ();
874 foreach (string invalid_name in invalid_char_names) {
875 name.Name = invalid_name;
877 AppDomain.CurrentDomain.DefineDynamicAssembly (
879 AssemblyBuilderAccess.Run,
880 AppDomain.CurrentDomain.Evidence,
881 (PermissionSet) null,
882 (PermissionSet) null,
883 (PermissionSet) null);
884 Assert.Fail ("#1:" + invalid_name);
885 } catch (ArgumentException ex) {
886 // Assembly names may not begin with whitespace
887 // or contain the characters '/', '\' or ':'
888 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
889 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
890 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
891 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
892 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
893 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
894 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
899 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence, PermissionSet, PermissionSet, PermissionSet)
900 public void DefineDynamicAssembly6_Name_Null ()
903 AppDomain.CurrentDomain.DefineDynamicAssembly (
905 AssemblyBuilderAccess.Run,
906 AppDomain.CurrentDomain.Evidence,
907 (PermissionSet) null,
908 (PermissionSet) null,
909 (PermissionSet) null);
911 } catch (ArgumentNullException ex) {
912 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
913 Assert.IsNull (ex.InnerException, "#A3");
914 Assert.IsNotNull (ex.Message, "#A4");
915 Assert.IsNotNull (ex.ParamName, "#A5");
916 Assert.AreEqual ("name", ex.ParamName, "#A6");
919 AssemblyName name = new AssemblyName ();
922 AppDomain.CurrentDomain.DefineDynamicAssembly (
924 AssemblyBuilderAccess.Run,
925 AppDomain.CurrentDomain.Evidence,
926 (PermissionSet) null,
927 (PermissionSet) null,
928 (PermissionSet) null);
930 } catch (ArgumentException ex) {
931 // AssemblyName.Name cannot be null or an empty string
932 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
933 Assert.IsNull (ex.InnerException, "#B3");
934 Assert.IsNotNull (ex.Message, "#B4");
935 Assert.IsNull (ex.ParamName, "#B5");
938 name.Name = string.Empty;
941 AppDomain.CurrentDomain.DefineDynamicAssembly (
943 AssemblyBuilderAccess.Run,
944 AppDomain.CurrentDomain.Evidence,
945 (PermissionSet) null,
946 (PermissionSet) null,
947 (PermissionSet) null);
949 } catch (ArgumentException ex) {
950 // AssemblyName.Name cannot be null or an empty string
951 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
952 Assert.IsNull (ex.InnerException, "#C3");
953 Assert.IsNotNull (ex.Message, "#C4");
954 Assert.IsNull (ex.ParamName, "#C5");
958 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, PermissionSet, PermissionSet, PermissionSet)
959 public void DefineDynamicAssembly7_Access_Invalid ()
961 AssemblyName name = new AssemblyName ();
962 name.Name = "DefineDynamicAssembly7";
966 AppDomain.CurrentDomain.DefineDynamicAssembly (
967 name, AssemblyBuilderAccess.Run |
968 (AssemblyBuilderAccess) 666,
970 (PermissionSet) null,
971 (PermissionSet) null,
972 (PermissionSet) null);
974 } catch (ArgumentException ex) {
975 // Illegal enum value: 667
976 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
977 Assert.IsNull (ex.InnerException, "#3");
978 Assert.IsNotNull (ex.Message, "#4");
979 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
980 Assert.IsNotNull (ex.ParamName, "#6");
981 Assert.AreEqual ("access", ex.ParamName, "#7");
984 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
985 name, AssemblyBuilderAccess.Run |
986 (AssemblyBuilderAccess) 666,
988 (PermissionSet) null,
989 (PermissionSet) null,
990 (PermissionSet) null);
991 Assert.IsNotNull (ab, "#1");
995 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, PermissionSet, PermissionSet, PermissionSet)
996 public void DefineDynamicAssembly7_Name_InvalidChars ()
998 string [] invalid_char_names = new string [] {
1008 AssemblyName name = new AssemblyName ();
1010 foreach (string invalid_name in invalid_char_names) {
1011 name.Name = invalid_name;
1013 AppDomain.CurrentDomain.DefineDynamicAssembly (
1015 AssemblyBuilderAccess.Run,
1016 Path.GetTempPath (),
1017 (PermissionSet) null,
1018 (PermissionSet) null,
1019 (PermissionSet) null);
1020 Assert.Fail ("#1:" + invalid_name);
1021 } catch (ArgumentException ex) {
1022 // Assembly names may not begin with whitespace
1023 // or contain the characters '/', '\' or ':'
1024 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
1025 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
1026 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
1027 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
1028 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
1029 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
1030 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
1035 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, PermissionSet, PermissionSet, PermissionSet)
1036 public void DefineDynamicAssembly7_Name_Null ()
1039 AppDomain.CurrentDomain.DefineDynamicAssembly (
1040 (AssemblyName) null,
1041 AssemblyBuilderAccess.Run,
1042 Path.GetTempPath (),
1043 (PermissionSet) null,
1044 (PermissionSet) null,
1045 (PermissionSet) null);
1046 Assert.Fail ("#A1");
1047 } catch (ArgumentNullException ex) {
1048 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1049 Assert.IsNull (ex.InnerException, "#A3");
1050 Assert.IsNotNull (ex.Message, "#A4");
1051 Assert.IsNotNull (ex.ParamName, "#A5");
1052 Assert.AreEqual ("name", ex.ParamName, "#A6");
1055 AssemblyName name = new AssemblyName ();
1058 AppDomain.CurrentDomain.DefineDynamicAssembly (
1060 AssemblyBuilderAccess.Run,
1061 Path.GetTempPath (),
1062 (PermissionSet) null,
1063 (PermissionSet) null,
1064 (PermissionSet) null);
1065 Assert.Fail ("#B1");
1066 } catch (ArgumentException ex) {
1067 // AssemblyName.Name cannot be null or an empty string
1068 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1069 Assert.IsNull (ex.InnerException, "#B3");
1070 Assert.IsNotNull (ex.Message, "#B4");
1071 Assert.IsNull (ex.ParamName, "#B5");
1074 name.Name = string.Empty;
1077 AppDomain.CurrentDomain.DefineDynamicAssembly (
1079 AssemblyBuilderAccess.Run,
1080 Path.GetTempPath (),
1081 (PermissionSet) null,
1082 (PermissionSet) null,
1083 (PermissionSet) null);
1084 Assert.Fail ("#C1");
1085 } catch (ArgumentException ex) {
1086 // AssemblyName.Name cannot be null or an empty string
1087 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1088 Assert.IsNull (ex.InnerException, "#C3");
1089 Assert.IsNotNull (ex.Message, "#C4");
1090 Assert.IsNull (ex.ParamName, "#C5");
1094 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet)
1095 public void DefineDynamicAssembly8_Access_Invalid ()
1097 AssemblyName name = new AssemblyName ();
1098 name.Name = "DefineDynamicAssembly8";
1102 AppDomain.CurrentDomain.DefineDynamicAssembly (
1103 name, AssemblyBuilderAccess.Run |
1104 (AssemblyBuilderAccess) 666,
1105 Path.GetTempPath (),
1106 AppDomain.CurrentDomain.Evidence,
1107 (PermissionSet) null,
1108 (PermissionSet) null,
1109 (PermissionSet) null);
1111 } catch (ArgumentException ex) {
1112 // Illegal enum value: 667
1113 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1114 Assert.IsNull (ex.InnerException, "#3");
1115 Assert.IsNotNull (ex.Message, "#4");
1116 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
1117 Assert.IsNotNull (ex.ParamName, "#6");
1118 Assert.AreEqual ("access", ex.ParamName, "#7");
1121 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1122 name, AssemblyBuilderAccess.Run |
1123 (AssemblyBuilderAccess) 666,
1124 Path.GetTempPath (),
1125 AppDomain.CurrentDomain.Evidence,
1126 (PermissionSet) null,
1127 (PermissionSet) null,
1128 (PermissionSet) null);
1129 Assert.IsNotNull (ab, "#1");
1133 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet)
1134 public void DefineDynamicAssembly8_Name_InvalidChars ()
1136 string [] invalid_char_names = new string [] {
1146 AssemblyName name = new AssemblyName ();
1148 foreach (string invalid_name in invalid_char_names) {
1149 name.Name = invalid_name;
1151 AppDomain.CurrentDomain.DefineDynamicAssembly (
1153 AssemblyBuilderAccess.Run,
1154 Path.GetTempPath (),
1155 AppDomain.CurrentDomain.Evidence,
1156 (PermissionSet) null,
1157 (PermissionSet) null,
1158 (PermissionSet) null);
1159 Assert.Fail ("#1:" + invalid_name);
1160 } catch (ArgumentException ex) {
1161 // Assembly names may not begin with whitespace
1162 // or contain the characters '/', '\' or ':'
1163 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
1164 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
1165 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
1166 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
1167 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
1168 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
1169 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
1174 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet)
1175 public void DefineDynamicAssembly8_Name_Null ()
1178 AppDomain.CurrentDomain.DefineDynamicAssembly (
1179 (AssemblyName) null,
1180 AssemblyBuilderAccess.Run,
1181 Path.GetTempPath (),
1182 AppDomain.CurrentDomain.Evidence,
1183 (PermissionSet) null,
1184 (PermissionSet) null,
1185 (PermissionSet) null);
1186 Assert.Fail ("#A1");
1187 } catch (ArgumentNullException ex) {
1188 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1189 Assert.IsNull (ex.InnerException, "#A3");
1190 Assert.IsNotNull (ex.Message, "#A4");
1191 Assert.IsNotNull (ex.ParamName, "#A5");
1192 Assert.AreEqual ("name", ex.ParamName, "#A6");
1195 AssemblyName name = new AssemblyName ();
1198 AppDomain.CurrentDomain.DefineDynamicAssembly (
1200 AssemblyBuilderAccess.Run,
1201 Path.GetTempPath (),
1202 AppDomain.CurrentDomain.Evidence,
1203 (PermissionSet) null,
1204 (PermissionSet) null,
1205 (PermissionSet) null);
1206 Assert.Fail ("#B1");
1207 } catch (ArgumentException ex) {
1208 // AssemblyName.Name cannot be null or an empty string
1209 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1210 Assert.IsNull (ex.InnerException, "#B3");
1211 Assert.IsNotNull (ex.Message, "#B4");
1212 Assert.IsNull (ex.ParamName, "#B5");
1215 name.Name = string.Empty;
1218 AppDomain.CurrentDomain.DefineDynamicAssembly (
1220 AssemblyBuilderAccess.Run,
1221 Path.GetTempPath (),
1222 AppDomain.CurrentDomain.Evidence,
1223 (PermissionSet) null,
1224 (PermissionSet) null,
1225 (PermissionSet) null);
1226 Assert.Fail ("#C1");
1227 } catch (ArgumentException ex) {
1228 // AssemblyName.Name cannot be null or an empty string
1229 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1230 Assert.IsNull (ex.InnerException, "#C3");
1231 Assert.IsNotNull (ex.Message, "#C4");
1232 Assert.IsNull (ex.ParamName, "#C5");
1236 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean)
1237 public void DefineDynamicAssembly9_Access_Invalid ()
1239 AssemblyName name = new AssemblyName ();
1240 name.Name = "DefineDynamicAssembly9";
1244 AppDomain.CurrentDomain.DefineDynamicAssembly (
1245 name, AssemblyBuilderAccess.Run |
1246 (AssemblyBuilderAccess) 666,
1247 Path.GetTempPath (),
1248 AppDomain.CurrentDomain.Evidence,
1249 (PermissionSet) null,
1250 (PermissionSet) null,
1251 (PermissionSet) null,
1254 } catch (ArgumentException ex) {
1255 // Illegal enum value: 667
1256 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1257 Assert.IsNull (ex.InnerException, "#3");
1258 Assert.IsNotNull (ex.Message, "#4");
1259 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
1260 Assert.IsNotNull (ex.ParamName, "#6");
1261 Assert.AreEqual ("access", ex.ParamName, "#7");
1264 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1265 name, AssemblyBuilderAccess.Run |
1266 (AssemblyBuilderAccess) 666,
1267 Path.GetTempPath (),
1268 AppDomain.CurrentDomain.Evidence,
1269 (PermissionSet) null,
1270 (PermissionSet) null,
1271 (PermissionSet) null,
1273 Assert.IsNotNull (ab, "#1");
1277 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean)
1278 public void DefineDynamicAssembly9_Name_InvalidChars ()
1280 string [] invalid_char_names = new string [] {
1290 AssemblyName name = new AssemblyName ();
1292 foreach (string invalid_name in invalid_char_names) {
1293 name.Name = invalid_name;
1295 AppDomain.CurrentDomain.DefineDynamicAssembly (
1297 AssemblyBuilderAccess.Run,
1298 Path.GetTempPath (),
1299 AppDomain.CurrentDomain.Evidence,
1300 (PermissionSet) null,
1301 (PermissionSet) null,
1302 (PermissionSet) null,
1304 Assert.Fail ("#1:" + invalid_name);
1305 } catch (ArgumentException ex) {
1306 // Assembly names may not begin with whitespace
1307 // or contain the characters '/', '\' or ':'
1308 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
1309 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
1310 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
1311 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
1312 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
1313 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
1314 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
1319 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean)
1320 public void DefineDynamicAssembly9_Name_Null ()
1323 AppDomain.CurrentDomain.DefineDynamicAssembly (
1324 (AssemblyName) null,
1325 AssemblyBuilderAccess.Run,
1326 Path.GetTempPath (),
1327 AppDomain.CurrentDomain.Evidence,
1328 (PermissionSet) null,
1329 (PermissionSet) null,
1330 (PermissionSet) null,
1332 Assert.Fail ("#A1");
1333 } catch (ArgumentNullException ex) {
1334 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1335 Assert.IsNull (ex.InnerException, "#A3");
1336 Assert.IsNotNull (ex.Message, "#A4");
1337 Assert.IsNotNull (ex.ParamName, "#A5");
1338 Assert.AreEqual ("name", ex.ParamName, "#A6");
1341 AssemblyName name = new AssemblyName ();
1344 AppDomain.CurrentDomain.DefineDynamicAssembly (
1346 AssemblyBuilderAccess.Run,
1347 Path.GetTempPath (),
1348 AppDomain.CurrentDomain.Evidence,
1349 (PermissionSet) null,
1350 (PermissionSet) null,
1351 (PermissionSet) null,
1353 Assert.Fail ("#B1");
1354 } catch (ArgumentException ex) {
1355 // AssemblyName.Name cannot be null or an empty string
1356 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1357 Assert.IsNull (ex.InnerException, "#B3");
1358 Assert.IsNotNull (ex.Message, "#B4");
1359 Assert.IsNull (ex.ParamName, "#B5");
1362 name.Name = string.Empty;
1365 AppDomain.CurrentDomain.DefineDynamicAssembly (
1367 AssemblyBuilderAccess.Run,
1368 Path.GetTempPath (),
1369 AppDomain.CurrentDomain.Evidence,
1370 (PermissionSet) null,
1371 (PermissionSet) null,
1372 (PermissionSet) null,
1374 Assert.Fail ("#C1");
1375 } catch (ArgumentException ex) {
1376 // AssemblyName.Name cannot be null or an empty string
1377 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1378 Assert.IsNull (ex.InnerException, "#C3");
1379 Assert.IsNotNull (ex.Message, "#C4");
1380 Assert.IsNull (ex.ParamName, "#C5");
1385 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
1386 public void DefineDynamicAssembly10_Access_Invalid ()
1388 AssemblyName name = new AssemblyName ();
1389 name.Name = "DefineDynamicAssembly10";
1393 AppDomain.CurrentDomain.DefineDynamicAssembly (
1394 name, AssemblyBuilderAccess.Run |
1395 (AssemblyBuilderAccess) 666,
1396 Path.GetTempPath (),
1397 AppDomain.CurrentDomain.Evidence,
1398 (PermissionSet) null,
1399 (PermissionSet) null,
1400 (PermissionSet) null,
1402 new List<CustomAttributeBuilder> ());
1404 } catch (ArgumentException ex) {
1405 // Illegal enum value: 667
1406 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1407 Assert.IsNull (ex.InnerException, "#3");
1408 Assert.IsNotNull (ex.Message, "#4");
1409 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
1410 Assert.IsNotNull (ex.ParamName, "#6");
1411 Assert.AreEqual ("access", ex.ParamName, "#7");
1414 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1415 name, AssemblyBuilderAccess.Run |
1416 (AssemblyBuilderAccess) 666,
1417 Path.GetTempPath (),
1418 AppDomain.CurrentDomain.Evidence,
1419 (PermissionSet) null,
1420 (PermissionSet) null,
1421 (PermissionSet) null,
1423 new List<CustomAttributeBuilder> ());
1424 Assert.IsNotNull (ab, "#1");
1428 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
1429 public void DefineDynamicAssembly10_Name_InvalidChars ()
1431 string [] invalid_char_names = new string [] {
1441 AssemblyName name = new AssemblyName ();
1443 foreach (string invalid_name in invalid_char_names) {
1444 name.Name = invalid_name;
1446 AppDomain.CurrentDomain.DefineDynamicAssembly (
1448 AssemblyBuilderAccess.Run,
1449 Path.GetTempPath (),
1450 AppDomain.CurrentDomain.Evidence,
1451 (PermissionSet) null,
1452 (PermissionSet) null,
1453 (PermissionSet) null,
1455 new List<CustomAttributeBuilder> ());
1456 Assert.Fail ("#1:" + invalid_name);
1457 } catch (ArgumentException ex) {
1458 // Assembly names may not begin with whitespace
1459 // or contain the characters '/', '\' or ':'
1460 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
1461 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
1462 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
1463 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
1464 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
1465 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
1466 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
1471 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
1472 public void DefineDynamicAssembly10_Name_Null ()
1475 AppDomain.CurrentDomain.DefineDynamicAssembly (
1476 (AssemblyName) null,
1477 AssemblyBuilderAccess.Run,
1478 Path.GetTempPath (),
1479 AppDomain.CurrentDomain.Evidence,
1480 (PermissionSet) null,
1481 (PermissionSet) null,
1482 (PermissionSet) null,
1484 new List<CustomAttributeBuilder> ());
1485 Assert.Fail ("#A1");
1486 } catch (ArgumentNullException ex) {
1487 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1488 Assert.IsNull (ex.InnerException, "#A3");
1489 Assert.IsNotNull (ex.Message, "#A4");
1490 Assert.IsNotNull (ex.ParamName, "#A5");
1491 Assert.AreEqual ("name", ex.ParamName, "#A6");
1494 AssemblyName name = new AssemblyName ();
1497 AppDomain.CurrentDomain.DefineDynamicAssembly (
1499 AssemblyBuilderAccess.Run,
1500 Path.GetTempPath (),
1501 AppDomain.CurrentDomain.Evidence,
1502 (PermissionSet) null,
1503 (PermissionSet) null,
1504 (PermissionSet) null,
1506 new List<CustomAttributeBuilder> ());
1507 Assert.Fail ("#B1");
1508 } catch (ArgumentException ex) {
1509 // AssemblyName.Name cannot be null or an empty string
1510 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1511 Assert.IsNull (ex.InnerException, "#B3");
1512 Assert.IsNotNull (ex.Message, "#B4");
1513 Assert.IsNull (ex.ParamName, "#B5");
1516 name.Name = string.Empty;
1519 AppDomain.CurrentDomain.DefineDynamicAssembly (
1521 AssemblyBuilderAccess.Run,
1522 Path.GetTempPath (),
1523 AppDomain.CurrentDomain.Evidence,
1524 (PermissionSet) null,
1525 (PermissionSet) null,
1526 (PermissionSet) null,
1528 new List<CustomAttributeBuilder> ());
1529 Assert.Fail ("#C1");
1530 } catch (ArgumentException ex) {
1531 // AssemblyName.Name cannot be null or an empty string
1532 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1533 Assert.IsNull (ex.InnerException, "#C3");
1534 Assert.IsNotNull (ex.Message, "#C4");
1535 Assert.IsNull (ex.ParamName, "#C5");
1539 [Test] // DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)
1540 public void DefineDynamicAssembly11 ()
1542 List<CustomAttributeBuilder> cattrs;
1546 string assemblyFile;
1547 string current_dir = Directory.GetCurrentDirectory ();
1549 name = new AssemblyName ();
1550 name.Name = "DefineDynamicAssembly11A";
1552 cattrs = new List<CustomAttributeBuilder> ();
1553 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyVersionAttribute).
1554 GetConstructor (new Type [] { typeof (string) }),
1555 new object [] { "1.2.3.4"}));
1556 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyCultureAttribute).
1557 GetConstructor (new Type [] { typeof (string) }),
1558 new object [] { "nl-BE"}));
1559 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyAlgorithmIdAttribute).
1560 GetConstructor (new Type [] { typeof (AssemblyHashAlgorithm) }),
1561 new object [] { AssemblyHashAlgorithm.MD5 }));
1562 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyFlagsAttribute).
1563 GetConstructor (new Type [] { typeof (uint) }),
1564 new object [] { (uint)0x0100 }));
1565 cattrs.Add (new CustomAttributeBuilder (typeof (CLSCompliantAttribute).
1566 GetConstructor (new Type [] { typeof (bool) }),
1567 new object [] { true }));
1569 ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1570 name, AssemblyBuilderAccess.Save, cattrs);
1572 ab.SetCustomAttribute (new CustomAttributeBuilder (typeof (ComVisibleAttribute).
1573 GetConstructor (new Type [] { typeof (bool) }),
1574 new object [] { true }));
1576 ab.Save ("DefineDynamicAssembly11A.dll");
1578 assemblyFile = Path.Combine (current_dir, "DefineDynamicAssembly11A.dll");
1581 AssemblyName an = AssemblyName.GetAssemblyName (assemblyFile);
1582 Assert.AreEqual (CultureInfo.InvariantCulture, an.CultureInfo, "#A1");
1583 Assert.AreEqual (AssemblyNameFlags.None, an.Flags, "#A2");
1584 Assert.AreEqual ("DefineDynamicAssembly11A, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", an.FullName, "#A3");
1585 Assert.IsNull (an.GetPublicKey (), "#A4");
1586 Assert.AreEqual (new byte [0], an.GetPublicKeyToken (), "#A5");
1587 Assert.AreEqual (AssemblyHashAlgorithm.SHA1, an.HashAlgorithm, "#A6");
1588 Assert.IsNull (an.KeyPair, "#A7");
1589 Assert.AreEqual ("DefineDynamicAssembly11A", an.Name, "#A8");
1590 //Assert.AreEqual (ProcessorArchitecture.MSIL, an.ProcessorArchitecture, "#A9");
1591 Assert.AreEqual (an.FullName, an.ToString (), "#A10");
1592 Assert.AreEqual (new Version (0, 0, 0, 0), an.Version, "#A11");
1593 Assert.AreEqual (AssemblyVersionCompatibility.SameMachine, an.VersionCompatibility, "#A12");
1597 using (FileStream fs = File.OpenRead (assemblyFile)) {
1598 byte [] buffer = new byte [fs.Length];
1599 fs.Read (buffer, 0, buffer.Length);
1600 a = Assembly.Load (buffer);
1603 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyVersionAttribute));
1604 Assert.IsNotNull (attr, "#A13a");
1605 Assert.AreEqual ("1.2.3.4", ((AssemblyVersionAttribute) attr).Version, "#A13b");
1606 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyCultureAttribute));
1607 Assert.IsNotNull (attr, "#A14a");
1608 Assert.AreEqual ("nl-BE", ((AssemblyCultureAttribute) attr).Culture, "#A14b");
1609 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyAlgorithmIdAttribute));
1610 Assert.IsNotNull (attr, "#A15a");
1611 Assert.AreEqual ((uint) AssemblyHashAlgorithm.MD5, ((AssemblyAlgorithmIdAttribute) attr).AlgorithmId, "#A15b");
1612 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyFlagsAttribute));
1613 Assert.IsNotNull (attr, "#A16a");
1614 Assert.AreEqual ((uint) 0x0100, ((AssemblyFlagsAttribute) attr).Flags, "#A16b");
1615 attr = Attribute.GetCustomAttribute (a, typeof (CLSCompliantAttribute));
1616 Assert.IsNotNull (attr, "#A17a");
1617 Assert.IsTrue (((CLSCompliantAttribute) attr).IsCompliant, "#A17b");
1618 attr = Attribute.GetCustomAttribute (a, typeof (ComVisibleAttribute));
1619 Assert.IsNotNull (attr, "#A18a");
1620 Assert.IsTrue (((ComVisibleAttribute) attr).Value, "#A18b");
1622 File.Delete (assemblyFile);
1625 name = new AssemblyName ();
1626 name.CultureInfo = new CultureInfo ("fr-BE");
1627 name.KeyPair = new StrongNameKeyPair (keyPair);
1628 name.Name = "DefineDynamicAssembly11B";
1629 name.Version = new Version (3, 2, 4, 1);
1631 cattrs = new List<CustomAttributeBuilder> ();
1632 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyVersionAttribute).
1633 GetConstructor (new Type [] { typeof (string) }),
1634 new object [] { "1.2.3.4"}));
1635 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyCultureAttribute).
1636 GetConstructor (new Type [] { typeof (string) }),
1637 new object [] { "nl-BE"}));
1638 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyAlgorithmIdAttribute).
1639 GetConstructor (new Type [] { typeof (AssemblyHashAlgorithm) }),
1640 new object [] { AssemblyHashAlgorithm.MD5 }));
1641 cattrs.Add (new CustomAttributeBuilder (typeof (AssemblyFlagsAttribute).
1642 GetConstructor (new Type [] { typeof (uint) }),
1643 new object [] { (uint)0x0100 }));
1644 cattrs.Add (new CustomAttributeBuilder (typeof (CLSCompliantAttribute).
1645 GetConstructor (new Type [] { typeof (bool) }),
1646 new object [] { true }));
1648 ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1649 name, AssemblyBuilderAccess.Save, cattrs);
1651 ab.SetCustomAttribute (new CustomAttributeBuilder (typeof (ComVisibleAttribute).
1652 GetConstructor (new Type [] { typeof (bool) }),
1653 new object [] { true }));
1655 ab.Save ("DefineDynamicAssembly11B.dll");
1657 assemblyFile = Path.Combine (current_dir, "DefineDynamicAssembly11B.dll");
1660 AssemblyName an = AssemblyName.GetAssemblyName (assemblyFile);
1661 Assert.AreEqual ("fr-BE", an.CultureInfo.Name, "#B1");
1662 Assert.AreEqual (AssemblyNameFlags.PublicKey, an.Flags, "#B2");
1663 Assert.AreEqual ("DefineDynamicAssembly11B, Version=3.2.4.1, Culture=fr-BE, PublicKeyToken=ce5276d8687ec6dc", an.FullName, "#B3");
1664 Assert.AreEqual (publicKey, an.GetPublicKey (), "#B4");
1665 Assert.AreEqual (pk_token, an.GetPublicKeyToken (), "#B5");
1666 Assert.AreEqual (AssemblyHashAlgorithm.SHA1, an.HashAlgorithm, "#B6");
1667 Assert.IsNull (an.KeyPair, "#B7");
1668 Assert.AreEqual ("DefineDynamicAssembly11B", an.Name, "#B8");
1669 //Assert.AreEqual (ProcessorArchitecture.MSIL, an.ProcessorArchitecture, "#B9");
1670 Assert.AreEqual (an.FullName, an.ToString (), "#B10");
1671 Assert.AreEqual (new Version (3, 2, 4, 1), an.Version, "#B11");
1672 Assert.AreEqual (AssemblyVersionCompatibility.SameMachine, an.VersionCompatibility, "#B12");
1676 using (FileStream fs = File.OpenRead (assemblyFile)) {
1677 byte [] buffer = new byte [fs.Length];
1678 fs.Read (buffer, 0, buffer.Length);
1679 a = Assembly.Load (buffer);
1682 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyVersionAttribute));
1683 Assert.IsNotNull (attr, "#B13a");
1684 Assert.AreEqual ("1.2.3.4", ((AssemblyVersionAttribute) attr).Version, "#B13b");
1685 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyCultureAttribute));
1686 Assert.IsNotNull (attr, "#B14a");
1687 Assert.AreEqual ("nl-BE", ((AssemblyCultureAttribute) attr).Culture, "#B14b");
1688 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyAlgorithmIdAttribute));
1689 Assert.IsNotNull (attr, "#B15a");
1690 Assert.AreEqual ((uint) AssemblyHashAlgorithm.MD5, ((AssemblyAlgorithmIdAttribute) attr).AlgorithmId, "#B15b");
1691 attr = Attribute.GetCustomAttribute (a, typeof (AssemblyFlagsAttribute));
1692 Assert.IsNotNull (attr, "#B16a");
1693 Assert.AreEqual ((uint) 0x0100, ((AssemblyFlagsAttribute) attr).Flags, "#B16b");
1694 attr = Attribute.GetCustomAttribute (a, typeof (CLSCompliantAttribute));
1695 Assert.IsNotNull (attr, "#B17a");
1696 Assert.IsTrue (((CLSCompliantAttribute) attr).IsCompliant, "#B17b");
1697 attr = Attribute.GetCustomAttribute (a, typeof (ComVisibleAttribute));
1698 Assert.IsNotNull (attr, "#B18a");
1699 Assert.IsTrue (((ComVisibleAttribute) attr).Value, "#B18b");
1701 File.Delete (assemblyFile);
1705 [Test] // DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)
1706 public void DefineDynamicAssembly11_Access_Invalid ()
1708 AssemblyName name = new AssemblyName ();
1709 name.Name = "DefineDynamicAssembly11";
1713 AppDomain.CurrentDomain.DefineDynamicAssembly (
1714 name, AssemblyBuilderAccess.Run |
1715 (AssemblyBuilderAccess) 666,
1716 new List<CustomAttributeBuilder> ());
1718 } catch (ArgumentException ex) {
1719 // Illegal enum value: 667
1720 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1721 Assert.IsNull (ex.InnerException, "#3");
1722 Assert.IsNotNull (ex.Message, "#4");
1723 Assert.IsTrue (ex.Message.IndexOf ("667") != -1, "#5");
1724 Assert.IsNotNull (ex.ParamName, "#6");
1725 Assert.AreEqual ("access", ex.ParamName, "#7");
1728 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
1729 name, AssemblyBuilderAccess.Run |
1730 (AssemblyBuilderAccess) 666,
1731 new List<CustomAttributeBuilder> ());
1732 Assert.IsNotNull (ab, "#1");
1736 [Test] // DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)
1737 public void DefineDynamicAssembly11_Name_InvalidChars ()
1739 string [] invalid_char_names = new string [] {
1749 AssemblyName name = new AssemblyName ();
1751 foreach (string invalid_name in invalid_char_names) {
1752 name.Name = invalid_name;
1754 AppDomain.CurrentDomain.DefineDynamicAssembly (
1756 AssemblyBuilderAccess.Run,
1757 new List<CustomAttributeBuilder> ());
1758 Assert.Fail ("#1:" + invalid_name);
1759 } catch (ArgumentException ex) {
1760 // Assembly names may not begin with whitespace
1761 // or contain the characters '/', '\' or ':'
1762 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + invalid_name);
1763 Assert.IsNull (ex.InnerException, "#3:" + invalid_name);
1764 Assert.IsNotNull (ex.Message, "#4:" + invalid_name);
1765 Assert.IsTrue (ex.Message.IndexOf ("'/'") != -1, "#5:" + invalid_name);
1766 Assert.IsTrue (ex.Message.IndexOf ("'\\'") != -1, "#6:" + invalid_name);
1767 Assert.IsTrue (ex.Message.IndexOf ("':'") != -1, "#7:" + invalid_name);
1768 Assert.IsNull (ex.ParamName, "#8:" + invalid_name);
1773 [Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
1774 public void DefineDynamicAssembly11_Name_Null ()
1777 AppDomain.CurrentDomain.DefineDynamicAssembly (
1778 (AssemblyName) null,
1779 AssemblyBuilderAccess.Run,
1780 new List<CustomAttributeBuilder> ());
1781 Assert.Fail ("#A1");
1782 } catch (ArgumentNullException ex) {
1783 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1784 Assert.IsNull (ex.InnerException, "#A3");
1785 Assert.IsNotNull (ex.Message, "#A4");
1786 Assert.IsNotNull (ex.ParamName, "#A5");
1787 Assert.AreEqual ("name", ex.ParamName, "#A6");
1790 AssemblyName name = new AssemblyName ();
1793 AppDomain.CurrentDomain.DefineDynamicAssembly (
1795 AssemblyBuilderAccess.Run,
1796 new List<CustomAttributeBuilder> ());
1797 Assert.Fail ("#B1");
1798 } catch (ArgumentException ex) {
1799 // AssemblyName.Name cannot be null or an empty string
1800 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1801 Assert.IsNull (ex.InnerException, "#B3");
1802 Assert.IsNotNull (ex.Message, "#B4");
1803 Assert.IsNull (ex.ParamName, "#B5");
1806 name.Name = string.Empty;
1809 AppDomain.CurrentDomain.DefineDynamicAssembly (
1811 AssemblyBuilderAccess.Run,
1812 new List<CustomAttributeBuilder> ());
1813 Assert.Fail ("#C1");
1814 } catch (ArgumentException ex) {
1815 // AssemblyName.Name cannot be null or an empty string
1816 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1817 Assert.IsNull (ex.InnerException, "#C3");
1818 Assert.IsNotNull (ex.Message, "#C4");
1819 Assert.IsNull (ex.ParamName, "#C5");
1823 [Test] // ExecuteAssemblyByName (String)
1824 public void ExecuteAssemblyByName1_NoEntryPoint ()
1827 AppDomain.CurrentDomain.ExecuteAssemblyByName ("mscorlib");
1829 } catch (MissingMethodException ex) {
1830 // Entry point not found in assembly '...'
1831 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
1832 Assert.IsNull (ex.InnerException, "#3");
1833 Assert.IsNotNull (ex.Message, "#4");
1834 Assert.IsTrue (ex.Message.IndexOf (Consts.AssemblyCorlib) != -1, "#5");
1838 [Test] // ExecuteAssemblyByName (String, Evidence)
1839 public void ExecuteAssemblyByName2_NoEntryPoint ()
1842 AppDomain.CurrentDomain.ExecuteAssemblyByName (
1843 "mscorlib", (Evidence) null);
1845 } catch (MissingMethodException ex) {
1846 // Entry point not found in assembly '...'
1847 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
1848 Assert.IsNull (ex.InnerException, "#3");
1849 Assert.IsNotNull (ex.Message, "#4");
1850 Assert.IsTrue (ex.Message.IndexOf (Consts.AssemblyCorlib) != -1, "#5");
1854 [Test] // ExecuteAssemblyByName (String, Evidence, String [])
1855 public void ExecuteAssemblyByName3_NoEntryPoint ()
1858 AppDomain.CurrentDomain.ExecuteAssemblyByName (
1859 "mscorlib", (Evidence) null,
1862 } catch (MissingMethodException ex) {
1863 // Entry point not found in assembly '...'
1864 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
1865 Assert.IsNull (ex.InnerException, "#3");
1866 Assert.IsNotNull (ex.Message, "#4");
1867 Assert.IsTrue (ex.Message.IndexOf (Consts.AssemblyCorlib) != -1, "#5");
1871 [Test] // ExecuteAssemblyByName (AssemblyName, Evidence, String [])
1872 public void ExecuteAssemblyByName4_NoEntryPoint ()
1874 AssemblyName aname = new AssemblyName ("mscorlib");
1877 AppDomain.CurrentDomain.ExecuteAssemblyByName (
1878 aname, (Evidence) null, new string [0]);
1880 } catch (MissingMethodException ex) {
1881 // Entry point not found in assembly '...'
1882 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
1883 Assert.IsNull (ex.InnerException, "#3");
1884 Assert.IsNotNull (ex.Message, "#4");
1885 Assert.IsTrue (ex.Message.IndexOf (Consts.AssemblyCorlib) != -1, "#5");
1891 public void SetThreadPrincipal ()
1893 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
1894 IPrincipal p = new GenericPrincipal (i, null);
1895 ad = AppDomain.CreateDomain ("SetThreadPrincipal");
1896 ad.SetThreadPrincipal (p);
1900 [ExpectedException (typeof (ArgumentNullException))]
1901 public void SetThreadPrincipalNull ()
1903 AppDomain.CurrentDomain.SetThreadPrincipal (null);
1907 [ExpectedException (typeof (PolicyException))]
1908 public void SetThreadPrincipalTwice ()
1910 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
1911 IPrincipal p = new GenericPrincipal (i, null);
1912 ad = AppDomain.CreateDomain ("SetThreadPrincipalTwice");
1913 ad.SetThreadPrincipal (p);
1914 // you only live twice (or so James told me ;-)
1915 ad.SetThreadPrincipal (p);
1919 [ExpectedException (typeof (AppDomainUnloadedException))]
1920 public void SetThreadPrincipalUnloaded ()
1922 ad = AppDomain.CreateDomain ("Ximian");
1923 AppDomain.Unload (ad);
1924 IIdentity i = new GenericIdentity ("sebastien@ximian.com", "rfc822");
1925 IPrincipal p = new GenericPrincipal (i, null);
1926 ad.SetThreadPrincipal (p);
1930 public void SetPrincipalPolicy_NoPrincipal ()
1932 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.NoPrincipal);
1936 public void SetPrincipalPolicy_UnauthenticatedPrincipal ()
1938 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.UnauthenticatedPrincipal);
1942 public void SetPrincipalPolicy_WindowsPrincipal ()
1944 AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.WindowsPrincipal);
1948 [ExpectedException (typeof (AppDomainUnloadedException))]
1949 public void SetPrincipalPolicyUnloaded ()
1951 ad = AppDomain.CreateDomain ("Ximian");
1952 AppDomain.Unload (ad);
1953 ad.SetPrincipalPolicy (PrincipalPolicy.NoPrincipal);
1957 public void CreateDomain_String ()
1959 ad = AppDomain.CreateDomain ("CreateDomain_String");
1960 Assert.IsNotNull (ad.Evidence, "Evidence");
1961 // Evidence are copied (or referenced?) from default app domain
1962 // we can't get default so we use the current (which should have copied the default)
1963 Assert.AreEqual (AppDomain.CurrentDomain.Evidence.Count, ad.Evidence.Count, "Evidence.Count");
1967 [ExpectedException (typeof (ArgumentNullException))]
1968 public void CreateDomain_String_Null ()
1970 ad = AppDomain.CreateDomain (null);
1974 [Category ("NotDotNet")]
1975 public void CreateDomain_StringEvidence ()
1977 Evidence e = new Evidence ();
1978 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidence", e);
1979 Assert.IsNotNull (ad.Evidence, "Evidence");
1980 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
1982 e.AddHost (new Zone (SecurityZone.MyComputer));
1983 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
1984 // evidence isn't copied but referenced
1988 [ExpectedException (typeof (ArgumentNullException))]
1989 public void CreateDomain_StringNullEvidence ()
1991 ad = AppDomain.CreateDomain (null, new Evidence ());
1995 public void CreateDomain_StringEvidenceNull ()
1997 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceNull", null);
1998 Assert.IsNotNull (ad.Evidence, "Evidence");
1999 // Evidence are copied (or referenced?) from default app domain
2000 // we can't get default so we use the current (which should have copied the default)
2001 Evidence e = AppDomain.CurrentDomain.Evidence;
2002 Assert.AreEqual (e.Count, ad.Evidence.Count, "Evidence.Count-1");
2003 e.AddHost (new Zone (SecurityZone.MyComputer));
2004 Assert.AreEqual (e.Count - 1, ad.Evidence.Count, "Evidence.Count-2");
2005 // evidence are copied
2009 [Category ("NotDotNet")]
2010 public void CreateDomain_StringEvidenceAppDomainSetup ()
2012 Evidence e = new Evidence ();
2013 AppDomainSetup info = new AppDomainSetup ();
2014 info.ApplicationName = "ApplicationName";
2016 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceAppDomainSetup", e, info);
2017 Assert.IsNotNull (ad.Evidence, "Evidence");
2018 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
2019 Assert.IsNotNull (ad.SetupInformation, "SetupInformation");
2020 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName);
2022 e.AddHost (new Zone (SecurityZone.MyComputer));
2023 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
2024 // evidence isn't copied but referenced
2028 [ExpectedException (typeof (ArgumentNullException))]
2029 public void CreateDomain_StringNullEvidenceAppDomainSetup ()
2031 AppDomainSetup info = new AppDomainSetup ();
2032 ad = AppDomain.CreateDomain (null, new Evidence (), info);
2036 public void CreateDomain_StringEvidenceNullAppDomainSetup ()
2038 AppDomainSetup info = new AppDomainSetup ();
2039 info.ApplicationName = "ApplicationName";
2040 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceNullAppDomainSetup", null, info);
2041 Assert.IsNotNull (ad.Evidence, "Evidence");
2042 // Evidence are copied (or referenced?) from default app domain
2043 // we can't get default so we use the current (which should have copied the default)
2044 Assert.AreEqual (AppDomain.CurrentDomain.Evidence.Count, ad.Evidence.Count, "Evidence.Count");
2045 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName, "ApplicationName-1");
2046 info.ApplicationName = "Test";
2047 Assert.AreEqual ("Test", info.ApplicationName, "ApplicationName-2");
2048 Assert.AreEqual ("ApplicationName", ad.SetupInformation.ApplicationName, "ApplicationName-3");
2053 [Category ("NotDotNet")]
2054 public void CreateDomain_StringEvidenceAppDomainSetupNull ()
2056 Evidence e = new Evidence ();
2057 ad = AppDomain.CreateDomain ("CreateDomain_StringEvidenceAppDomainSetupNull", e, null);
2058 Assert.IsNotNull (ad.Evidence, "Evidence");
2059 Assert.AreEqual (0, ad.Evidence.Count, "Evidence.Count");
2060 // SetupInformation is copied from default app domain
2061 Assert.IsNotNull (ad.SetupInformation, "SetupInformation");
2064 [Test] // ExecuteAssembly (String)
2065 public void ExecuteAssembly1_NoEntryPoint ()
2067 Assembly assembly = typeof (AppDomainTest).Assembly;
2070 AppDomain.CurrentDomain.ExecuteAssembly (
2074 } catch (MissingMethodException ex) {
2075 // Entry point not found in assembly '...'
2076 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
2077 Assert.IsNull (ex.InnerException, "#3");
2078 Assert.IsNotNull (ex.Message, "#4");
2079 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
2082 } catch (COMException ex) {
2083 // Unspecified error
2084 Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
2085 Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
2086 Assert.IsNull (ex.InnerException, "#4");
2087 Assert.IsNotNull (ex.Message, "#5");
2092 [Test] // ExecuteAssembly (String, Evidence)
2093 public void ExecuteAssembly2_NoEntryPoint ()
2095 Assembly assembly = typeof (AppDomainTest).Assembly;
2098 AppDomain.CurrentDomain.ExecuteAssembly (
2103 } catch (MissingMethodException ex) {
2104 // Entry point not found in assembly '...'
2105 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
2106 Assert.IsNull (ex.InnerException, "#3");
2107 Assert.IsNotNull (ex.Message, "#4");
2108 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
2111 } catch (COMException ex) {
2112 // Unspecified error
2113 Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
2114 Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
2115 Assert.IsNull (ex.InnerException, "#4");
2116 Assert.IsNotNull (ex.Message, "#5");
2121 [Test] // ExecuteAssembly (String, Evidence, String [])
2122 public void ExecuteAssembly3_NoEntryPoint ()
2124 Assembly assembly = typeof (AppDomainTest).Assembly;
2127 AppDomain.CurrentDomain.ExecuteAssembly (
2133 } catch (MissingMethodException ex) {
2134 // Entry point not found in assembly '...'
2135 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
2136 Assert.IsNull (ex.InnerException, "#3");
2137 Assert.IsNotNull (ex.Message, "#4");
2138 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
2141 } catch (COMException ex) {
2142 // Unspecified error
2143 Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
2144 Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
2145 Assert.IsNull (ex.InnerException, "#4");
2146 Assert.IsNotNull (ex.Message, "#5");
2151 [Test] // ExecuteAssembly (String, Evidence, String [], Byte [], AssemblyHashAlgorithm)
2152 [Category ("NotWorking")] // Not implemented
2153 public void ExecuteAssembly4_NoEntryPoint ()
2155 Assembly assembly = typeof (AppDomainTest).Assembly;
2158 AppDomain.CurrentDomain.ExecuteAssembly (
2163 AssemblyHashAlgorithm.SHA1);
2166 } catch (MissingMethodException ex) {
2167 // Entry point not found in assembly '...'
2168 Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
2169 Assert.IsNull (ex.InnerException, "#3");
2170 Assert.IsNotNull (ex.Message, "#4");
2171 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
2174 } catch (COMException ex) {
2175 // Unspecified error
2176 Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
2177 Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
2178 Assert.IsNull (ex.InnerException, "#4");
2179 Assert.IsNotNull (ex.Message, "#5");
2184 [Test] // bug #79720
2185 [Category ("NotWorking")]
2186 public void Load_Loaded_Ignore ()
2188 int assemblyStartCount = AppDomain.CurrentDomain.GetAssemblies ().Length;
2192 string assemblyFile = Path.Combine (tempDir, "bug79720A.dll");
2193 AssemblyName aname = new AssemblyName ();
2194 aname.Name = "bug79720A";
2195 aname.Version = new Version (2, 4);
2197 GenerateAssembly (aname, assemblyFile);
2199 Assert.AreEqual (assemblyStartCount, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A1");
2201 aname = new AssemblyName ();
2202 aname.Name = "bug79720A";
2204 AppDomain.CurrentDomain.Load (aname);
2205 Assert.Fail ("#A2");
2206 } catch (FileNotFoundException) {
2209 aname = new AssemblyName ();
2210 aname.Name = "bug79720A";
2211 aname.Version = new Version (0, 0, 0, 0);
2213 AppDomain.CurrentDomain.Load (aname);
2214 Assert.Fail ("#A3");
2215 } catch (FileNotFoundException) {
2218 aname = new AssemblyName ();
2219 aname.Name = "bug79720A";
2220 aname.Version = new Version (2, 4);
2222 AppDomain.CurrentDomain.Load (aname);
2223 Assert.Fail ("#A4");
2224 } catch (FileNotFoundException) {
2227 Assert.AreEqual (assemblyStartCount, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A5");
2229 Assembly.LoadFrom (assemblyFile);
2231 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A6");
2233 aname = new AssemblyName ();
2234 aname.Name = "bug79720A";
2236 AppDomain.CurrentDomain.Load (aname);
2237 Assert.Fail ("#A7");
2238 } catch (FileNotFoundException) {
2241 aname = new AssemblyName ();
2242 aname.Name = "bug79720A";
2243 aname.Version = new Version (0, 0, 0, 0);
2245 AppDomain.CurrentDomain.Load (aname);
2246 Assert.Fail ("#A8");
2247 } catch (FileNotFoundException) {
2250 aname = new AssemblyName ();
2251 aname.Name = "bug79720A";
2252 aname.Version = new Version (2, 4);
2254 AppDomain.CurrentDomain.Load (aname);
2255 Assert.Fail ("#A9");
2256 } catch (FileNotFoundException) {
2259 aname = new AssemblyName ();
2260 aname.Name = "bug79720A";
2261 aname.Version = new Version (2, 4);
2262 aname.CultureInfo = CultureInfo.InvariantCulture;
2264 AppDomain.CurrentDomain.Load (aname);
2265 Assert.Fail ("#A10");
2266 } catch (FileNotFoundException) {
2269 aname = new AssemblyName ();
2270 aname.Name = "bug79720A";
2271 aname.Version = new Version (2, 4, 0, 0);
2272 aname.CultureInfo = CultureInfo.InvariantCulture;
2274 AppDomain.CurrentDomain.Load (aname);
2275 Assert.Fail ("#A11");
2276 } catch (FileNotFoundException) {
2279 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#A12");
2283 assemblyFile = Path.Combine (tempDir, "bug79720B.dll");
2284 aname = new AssemblyName ();
2285 aname.Name = "bug79720B";
2286 aname.Version = new Version (2, 4, 1);
2287 aname.CultureInfo = new CultureInfo ("nl-BE");
2289 GenerateAssembly (aname, assemblyFile);
2291 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B1");
2293 aname = new AssemblyName ();
2294 aname.Name = "bug79720B";
2296 AppDomain.CurrentDomain.Load (aname);
2297 Assert.Fail ("#B2");
2298 } catch (FileNotFoundException) {
2301 aname = new AssemblyName ();
2302 aname.Name = "bug79720B";
2303 aname.Version = new Version (0, 0, 0, 0);
2305 AppDomain.CurrentDomain.Load (aname);
2306 Assert.Fail ("#B3");
2307 } catch (FileNotFoundException) {
2310 aname = new AssemblyName ();
2311 aname.Name = "bug79720B";
2312 aname.Version = new Version (2, 4, 1);
2314 AppDomain.CurrentDomain.Load (aname);
2315 Assert.Fail ("#B4");
2316 } catch (FileNotFoundException) {
2319 aname = new AssemblyName ();
2320 aname.Name = "bug79720B";
2321 aname.Version = new Version (2, 4, 1);
2322 aname.CultureInfo = new CultureInfo ("nl-BE");
2324 AppDomain.CurrentDomain.Load (aname);
2325 Assert.Fail ("#B5");
2326 } catch (FileNotFoundException) {
2329 Assert.AreEqual (assemblyStartCount + 1, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B6");
2331 Assembly.LoadFrom (assemblyFile);
2333 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B7");
2335 aname = new AssemblyName ();
2336 aname.Name = "bug79720B";
2338 AppDomain.CurrentDomain.Load (aname);
2339 Assert.Fail ("#B8");
2340 } catch (FileNotFoundException) {
2343 aname = new AssemblyName ();
2344 aname.Name = "bug79720B";
2345 aname.Version = new Version (0, 0, 0, 0);
2347 AppDomain.CurrentDomain.Load (aname);
2348 Assert.Fail ("#B9");
2349 } catch (FileNotFoundException) {
2352 aname = new AssemblyName ();
2353 aname.Name = "bug79720B";
2354 aname.Version = new Version (2, 4, 1);
2356 AppDomain.CurrentDomain.Load (aname);
2357 Assert.Fail ("#B10");
2358 } catch (FileNotFoundException) {
2361 aname = new AssemblyName ();
2362 aname.Name = "bug79720B";
2363 aname.Version = new Version (2, 4, 1);
2364 aname.CultureInfo = new CultureInfo ("nl-BE");
2366 AppDomain.CurrentDomain.Load (aname);
2367 Assert.Fail ("#B11");
2368 } catch (FileNotFoundException) {
2371 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#B12");
2375 assemblyFile = Path.Combine (tempDir, "bug79720C.dll");
2376 aname = new AssemblyName ();
2377 aname.Name = "bug79720C";
2378 aname.CultureInfo = new CultureInfo ("nl-BE");
2379 aname.Version = new Version (2, 4);
2380 aname.KeyPair = new StrongNameKeyPair (keyPair);
2382 GenerateAssembly (aname, assemblyFile);
2384 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C1");
2386 aname = new AssemblyName ();
2387 aname.Name = "bug79720C";
2389 AppDomain.CurrentDomain.Load (aname);
2390 Assert.Fail ("#C2");
2391 } catch (FileNotFoundException) {
2394 aname = new AssemblyName ();
2395 aname.Name = "bug79720C";
2396 aname.Version = new Version (0, 0, 0, 0);
2398 AppDomain.CurrentDomain.Load (aname);
2399 Assert.Fail ("#C3");
2400 } catch (FileNotFoundException) {
2403 aname = new AssemblyName ();
2404 aname.Name = "bug79720C";
2405 aname.Version = new Version (2, 4, 1);
2407 AppDomain.CurrentDomain.Load (aname);
2408 Assert.Fail ("#C4");
2409 } catch (FileNotFoundException) {
2412 aname = new AssemblyName ();
2413 aname.Name = "bug79720C";
2414 aname.Version = new Version (2, 4, 1);
2415 aname.CultureInfo = new CultureInfo ("nl-BE");
2417 AppDomain.CurrentDomain.Load (aname);
2418 Assert.Fail ("#C5");
2419 } catch (FileNotFoundException) {
2422 aname = new AssemblyName ();
2423 aname.Name = "bug79720C";
2424 aname.Version = new Version (2, 4, 1);
2425 aname.CultureInfo = new CultureInfo ("nl-BE");
2426 aname.SetPublicKey (publicKey);
2428 AppDomain.CurrentDomain.Load (aname);
2429 Assert.Fail ("#C6");
2430 } catch (FileNotFoundException) {
2433 Assert.AreEqual (assemblyStartCount + 2, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C7");
2435 Assembly.LoadFrom (assemblyFile);
2437 Assert.AreEqual (assemblyStartCount + 3, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C8");
2439 aname = new AssemblyName ();
2440 aname.Name = "bug79720C";
2442 AppDomain.CurrentDomain.Load (aname);
2443 Assert.Fail ("#C9");
2444 } catch (FileNotFoundException) {
2447 aname = new AssemblyName ();
2448 aname.Name = "bug79720C";
2449 aname.Version = new Version (0, 0, 0, 0);
2451 AppDomain.CurrentDomain.Load (aname);
2452 Assert.Fail ("#C10");
2453 } catch (FileNotFoundException) {
2456 aname = new AssemblyName ();
2457 aname.Name = "bug79720C";
2458 aname.Version = new Version (2, 4);
2460 AppDomain.CurrentDomain.Load (aname);
2461 Assert.Fail ("#C11");
2462 } catch (FileNotFoundException) {
2465 aname = new AssemblyName ();
2466 aname.Name = "bug79720C";
2467 aname.Version = new Version (2, 4);
2468 aname.CultureInfo = new CultureInfo ("nl-BE");
2470 AppDomain.CurrentDomain.Load (aname);
2471 Assert.Fail ("#C12");
2472 } catch (FileNotFoundException) {
2475 aname = new AssemblyName ();
2476 aname.Name = "bug79720C";
2477 aname.Version = new Version (2, 4);
2478 aname.CultureInfo = new CultureInfo ("nl-BE");
2479 aname.SetPublicKey (publicKey);
2481 AppDomain.CurrentDomain.Load (aname);
2482 Assert.Fail ("#C13");
2483 } catch (FileNotFoundException) {
2486 Assert.AreEqual (assemblyStartCount + 3, AppDomain.CurrentDomain.GetAssemblies ().Length, "#C14");
2490 [Category ("NotWorking")]
2491 public void Load_Loaded_Multiple ()
2493 string cultureDir = Path.Combine (tempDir, "nl-BE");
2494 if (!Directory.Exists (cultureDir))
2495 Directory.CreateDirectory (cultureDir);
2497 AppDomain ad = CreateTestDomain (tempDir, true);
2499 CrossDomainTester cdt = CreateCrossDomainTester (ad);
2501 int assemblyCount = cdt.AssemblyCount;
2505 AssemblyName aname = new AssemblyName ();
2506 aname.Name = "multipleA";
2507 aname.Version = new Version (1, 2, 3, 4);
2508 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "multipleA.dll"));
2510 Assert.AreEqual (assemblyCount + 1, cdt.AssemblyCount, "#A1");
2512 aname = new AssemblyName ();
2513 aname.Name = "multipleA";
2514 Assert.IsTrue (cdt.AssertLoad (aname), "#A2");
2516 Assert.AreEqual (assemblyCount + 2, cdt.AssemblyCount, "#A3");
2518 aname = new AssemblyName ();
2519 aname.Name = "multipleA";
2520 Assert.IsTrue (cdt.AssertLoad (aname), "#A4");
2522 aname = new AssemblyName ();
2523 aname.Name = "multipleA";
2524 aname.CultureInfo = CultureInfo.InvariantCulture;
2525 Assert.IsTrue (cdt.AssertLoad (aname), "#A5");
2527 aname = new AssemblyName ();
2528 aname.Name = "multipleA";
2529 aname.CultureInfo = CultureInfo.InvariantCulture;
2530 Assert.IsTrue (cdt.AssertLoad (aname), "#A6");
2532 aname = new AssemblyName ();
2533 aname.Name = "multipleA";
2534 aname.CultureInfo = CultureInfo.InvariantCulture;
2535 aname.Version = new Version (1, 2, 3, 4);
2536 Assert.IsTrue (cdt.AssertLoad (aname), "#A7");
2538 aname = new AssemblyName ();
2539 aname.Name = "multipleA";
2540 aname.CultureInfo = CultureInfo.InvariantCulture;
2541 aname.Version = new Version (1, 2, 3, 4);
2542 Assert.IsTrue (cdt.AssertLoad (aname), "#A8");
2544 Assert.AreEqual (assemblyCount + 2, cdt.AssemblyCount, "#A9");
2548 aname = new AssemblyName ();
2549 aname.Name = "multipleB";
2550 aname.CultureInfo = new CultureInfo ("nl-BE");
2551 aname.Version = new Version (2, 4, 1, 0);
2552 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "nl-BE/multipleB.dll"));
2554 Assert.AreEqual (assemblyCount + 3, cdt.AssemblyCount, "#B1");
2556 aname = new AssemblyName ();
2557 aname.Name = "multipleB";
2558 Assert.IsTrue (cdt.AssertLoad (aname), "#B2");
2560 Assert.AreEqual (assemblyCount + 4, cdt.AssemblyCount, "#B3");
2562 aname = new AssemblyName ();
2563 aname.Name = "multipleB";
2564 Assert.IsTrue (cdt.AssertLoad (aname), "#B4");
2566 aname = new AssemblyName ();
2567 aname.Name = "multipleB";
2568 aname.CultureInfo = new CultureInfo ("nl-BE");
2569 Assert.IsTrue (cdt.AssertLoad (aname), "#B5");
2571 aname = new AssemblyName ();
2572 aname.Name = "multipleB";
2573 aname.CultureInfo = new CultureInfo ("nl-BE");
2574 Assert.IsTrue (cdt.AssertLoad (aname), "#B6");
2576 aname = new AssemblyName ();
2577 aname.Name = "multipleB";
2578 aname.CultureInfo = new CultureInfo ("nl-BE");
2579 aname.Version = new Version (2, 4, 1, 0);
2580 Assert.IsTrue (cdt.AssertLoad (aname), "#B7");
2582 aname = new AssemblyName ();
2583 aname.Name = "multipleB";
2584 aname.CultureInfo = new CultureInfo ("nl-BE");
2585 aname.Version = new Version (2, 4, 1, 0);
2586 Assert.IsTrue (cdt.AssertLoad (aname), "#B8");
2588 Assert.AreEqual (assemblyCount + 4, cdt.AssemblyCount, "#B9");
2592 aname = new AssemblyName ();
2593 aname.Name = "multipleC";
2594 aname.CultureInfo = new CultureInfo ("nl-BE");
2595 aname.Version = new Version (2, 4, 0, 0);
2596 aname.KeyPair = new StrongNameKeyPair (keyPair);
2597 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "nl-BE/multipleC.dll"));
2599 Assert.AreEqual (assemblyCount + 5, cdt.AssemblyCount, "#C1");
2601 aname = new AssemblyName ();
2602 aname.Name = "multipleC";
2603 aname.CultureInfo = new CultureInfo ("nl-BE");
2604 aname.Version = new Version (2, 4, 0, 0);
2605 aname.SetPublicKey (publicKey);
2606 Assert.IsTrue (cdt.AssertLoad (aname), "#C2");
2608 Assert.AreEqual (assemblyCount + 6, cdt.AssemblyCount, "#C3");
2610 aname = new AssemblyName ();
2611 aname.Name = "multipleC";
2612 aname.CultureInfo = new CultureInfo ("nl-BE");
2613 aname.Version = new Version (2, 4, 0, 0);
2614 aname.SetPublicKey (publicKey);
2615 Assert.IsTrue (cdt.AssertLoad (aname), "#C4");
2617 Assert.AreEqual (assemblyCount + 6, cdt.AssemblyCount, "#C5");
2619 AppDomain.Unload (ad);
2623 [Test] // bug #79522
2624 [Category ("NotWorking")]
2625 public void Load_Manifest_Mismatch ()
2627 string assemblyFile = Path.Combine (tempDir, "bug79522A.dll");
2628 AssemblyName aname = new AssemblyName ();
2629 aname.Name = "bug79522A";
2630 aname.Version = new Version (2, 4);
2632 GenerateAssembly (aname, assemblyFile);
2634 aname = new AssemblyName ();
2635 aname.CodeBase = assemblyFile;
2636 aname.Name = "whateveryouwant";
2637 aname.Version = new Version (1, 1);
2639 // despite the fact that no assembly with the specified name
2640 // exists, the assembly pointed to by the CodeBase of the
2641 // AssemblyName will be loaded
2643 // however the display name of the loaded assembly does not
2644 // match the display name of the AssemblyName, and as a result
2645 // a FileLoadException is thrown
2647 AppDomain.CurrentDomain.Load (aname);
2648 Assert.Fail ("#A1");
2649 } catch (FileLoadException) {
2652 // if we set CodeBase to some garbage, then we'll get a
2653 // FileNotFoundException instead
2654 aname.CodeBase = "whatever";
2656 AppDomain.CurrentDomain.Load (aname);
2657 Assert.Fail ("#A2");
2658 } catch (FileNotFoundException) {
2661 aname = new AssemblyName ();
2662 aname.Name = "bug79522A";
2663 aname.CodeBase = assemblyFile;
2665 AppDomain.CurrentDomain.Load (aname);
2668 AppDomain.CurrentDomain.Load (aname);
2669 Assert.Fail ("#A3");
2670 } catch (FileLoadException) {
2674 aname = new AssemblyName ();
2675 aname.Name = "bug79522A";
2676 aname.CodeBase = assemblyFile;
2677 aname.Version = new Version (2, 5);
2679 // the version number is not considered when comparing the manifest
2680 // of the assembly found using codebase
2681 AppDomain.CurrentDomain.Load (aname);
2684 AppDomain.CurrentDomain.Load (aname);
2685 Assert.Fail ("#A4");
2686 } catch (FileLoadException) {
2690 aname = new AssemblyName ();
2691 aname.Name = "bug79522A";
2692 aname.CodeBase = assemblyFile;
2693 aname.Version = new Version (2, 4, 1);
2695 // the version number is not considered when comparing the manifest
2696 // of the assembly found using codebase
2697 AppDomain.CurrentDomain.Load (aname);
2700 AppDomain.CurrentDomain.Load (aname);
2701 Assert.Fail ("#A5");
2702 } catch (FileLoadException) {
2706 // if version is set, then culture must also be set
2707 aname = new AssemblyName ();
2708 aname.Name = "bug79522A";
2709 aname.CodeBase = assemblyFile;
2710 aname.Version = new Version (2, 4);
2712 AppDomain.CurrentDomain.Load (aname);
2715 AppDomain.CurrentDomain.Load (aname);
2716 Assert.Fail ("#A6");
2717 } catch (FileLoadException) {
2721 // version number does not need to be set
2722 aname = new AssemblyName ();
2723 aname.Name = "bug79522A";
2724 aname.CodeBase = assemblyFile;
2725 aname.CultureInfo = CultureInfo.InvariantCulture;
2726 AppDomain.CurrentDomain.Load (aname);
2728 // if set, the version number must match exactly
2729 aname = new AssemblyName ();
2730 aname.Name = "bug79522A";
2731 aname.CodeBase = assemblyFile;
2732 aname.CultureInfo = CultureInfo.InvariantCulture;
2733 aname.Version = new Version (2, 4);
2734 AppDomain.CurrentDomain.Load (aname);
2736 // if both culture and version are set, then the version diff
2738 aname = new AssemblyName ();
2739 aname.Name = "bug79522A";
2740 aname.CodeBase = assemblyFile;
2741 aname.CultureInfo = CultureInfo.InvariantCulture;
2742 aname.Version = new Version (2, 5);
2743 AppDomain.CurrentDomain.Load (aname);
2745 // loaded assembly is not signed
2746 aname = new AssemblyName ();
2747 aname.Name = "bug79522A";
2748 aname.CodeBase = assemblyFile;
2749 aname.CultureInfo = CultureInfo.InvariantCulture;
2750 aname.Version = new Version (2, 4);
2751 aname.SetPublicKey (publicKey);
2753 AppDomain.CurrentDomain.Load (aname);
2754 Assert.Fail ("#A7");
2755 } catch (FileLoadException) {
2758 // if set, the culture must match
2759 aname = new AssemblyName ();
2760 aname.Name = "bug79522A";
2761 aname.CodeBase = assemblyFile;
2762 aname.Version = new Version (2, 4);
2763 aname.CultureInfo = new CultureInfo ("en-US");
2765 AppDomain.CurrentDomain.Load (aname);
2766 Assert.Fail ("#A8");
2767 } catch (FileLoadException) {
2772 assemblyFile = Path.Combine (tempDir, "bug79522B.dll");
2773 aname = new AssemblyName ();
2774 aname.Name = "bug79522B";
2775 aname.CultureInfo = new CultureInfo ("nl-BE");
2776 aname.Version = new Version (2, 4, 1);
2778 GenerateAssembly (aname, assemblyFile);
2780 aname = new AssemblyName ();
2781 aname.CodeBase = assemblyFile;
2782 aname.Name = "whateveryouwant";
2783 aname.CultureInfo = new CultureInfo ("nl-BE");
2784 aname.Version = new Version (1, 1);
2786 // despite the fact that no assembly with the specified name
2787 // exists, the assembly pointed to by the CodeBase of the
2788 // AssemblyName will be loaded
2790 // however the display name of the loaded assembly does not
2791 // match the display name of the AssemblyName, and as a result
2792 // a FileLoadException is thrown
2794 AppDomain.CurrentDomain.Load (aname);
2795 Assert.Fail ("#B1");
2796 } catch (FileLoadException) {
2799 // if we set CodeBase to some garbage, then we'll get a
2800 // FileNotFoundException instead
2801 aname.CodeBase = "whatever";
2803 AppDomain.CurrentDomain.Load (aname);
2804 Assert.Fail ("#B2");
2805 } catch (FileNotFoundException) {
2808 aname = new AssemblyName ();
2809 aname.Name = "bug79522B";
2810 aname.CodeBase = assemblyFile;
2812 // the version number is not considered when comparing the manifest
2813 // of the assembly found using codebase
2814 AppDomain.CurrentDomain.Load (aname);
2817 AppDomain.CurrentDomain.Load (aname);
2818 Assert.Fail ("#B3");
2819 } catch (FileLoadException) {
2823 aname = new AssemblyName ();
2824 aname.Name = "bug79522B";
2825 aname.CodeBase = assemblyFile;
2826 aname.Version = new Version (5, 5);
2828 // the version number is not considered when comparing the manifest
2829 // of the assembly found using codebase
2830 AppDomain.CurrentDomain.Load (aname);
2833 AppDomain.CurrentDomain.Load (aname);
2834 Assert.Fail ("#B3");
2835 } catch (FileLoadException) {
2839 aname = new AssemblyName ();
2840 aname.Name = "bug79522B";
2841 aname.CodeBase = assemblyFile;
2842 aname.Version = new Version (2, 4, 1);
2844 AppDomain.CurrentDomain.Load (aname);
2846 // when the loaded assembly has a specific culture, then that
2847 // culture must be set if you set the Version on the aname
2849 AppDomain.CurrentDomain.Load (aname);
2850 Assert.Fail ("#B4");
2851 } catch (FileLoadException) {
2855 // version does not need to be set
2856 aname = new AssemblyName ();
2857 aname.Name = "bug79522B";
2858 aname.CodeBase = assemblyFile;
2859 aname.CultureInfo = new CultureInfo ("nl-BE");
2860 AppDomain.CurrentDomain.Load (aname);
2862 // if both culture and version are set, then the version diff
2864 aname = new AssemblyName ();
2865 aname.Name = "bug79522B";
2866 aname.CodeBase = assemblyFile;
2867 aname.CultureInfo = new CultureInfo ("nl-BE");
2868 aname.Version = new Version (6, 5);
2869 AppDomain.CurrentDomain.Load (aname);
2871 // loaded assembly is not signed
2872 aname = new AssemblyName ();
2873 aname.Name = "bug79522B";
2874 aname.CodeBase = assemblyFile;
2875 aname.CultureInfo = new CultureInfo ("nl-BE");
2876 aname.SetPublicKey (publicKey);
2878 AppDomain.CurrentDomain.Load (aname);
2879 Assert.Fail ("#B5");
2880 } catch (FileLoadException) {
2883 // if set, the culture must match
2884 aname = new AssemblyName ();
2885 aname.Name = "bug79522B";
2886 aname.CodeBase = assemblyFile;
2887 aname.Version = new Version (2, 4, 1);
2888 aname.CultureInfo = new CultureInfo ("en-US");
2890 AppDomain.CurrentDomain.Load (aname);
2891 Assert.Fail ("#B6");
2892 } catch (FileLoadException) {
2897 assemblyFile = Path.Combine (tempDir, "bug79522C.dll");
2898 aname = new AssemblyName ();
2899 aname.Name = "bug79522C";
2900 aname.CultureInfo = new CultureInfo ("nl-BE");
2901 aname.Version = new Version (2, 4);
2902 aname.KeyPair = new StrongNameKeyPair (keyPair);
2904 GenerateAssembly (aname, assemblyFile);
2906 aname = new AssemblyName ();
2907 aname.CodeBase = assemblyFile;
2908 aname.Name = "whateveryouwant";
2909 aname.CultureInfo = new CultureInfo ("nl-BE");
2910 aname.Version = new Version (1, 1);
2911 aname.SetPublicKey (publicKey);
2913 // despite the fact that no assembly with the specified name
2914 // exists, the assembly pointed to by the CodeBase of the
2915 // AssemblyName will be loaded
2917 // however the display name of the loaded assembly does not
2918 // match the display name of the AssemblyName, and as a result
2919 // a FileLoadException is thrown
2921 AppDomain.CurrentDomain.Load (aname);
2922 Assert.Fail ("#C1");
2923 } catch (FileLoadException) {
2926 // if we set CodeBase to some garbage, then we'll get a
2927 // FileNotFoundException instead
2928 aname.CodeBase = "whatever";
2930 AppDomain.CurrentDomain.Load (aname);
2931 Assert.Fail ("#C2");
2932 } catch (FileNotFoundException) {
2935 aname = new AssemblyName ();
2936 aname.Name = "bug79522C";
2937 aname.CodeBase = assemblyFile;
2939 AppDomain.CurrentDomain.Load (aname);
2942 AppDomain.CurrentDomain.Load (aname);
2943 Assert.Fail ("#C3");
2944 } catch (FileLoadException) {
2948 aname = new AssemblyName ();
2949 aname.Name = "bug79522C";
2950 aname.CodeBase = assemblyFile;
2951 aname.Version = new Version (5, 5);
2953 AppDomain.CurrentDomain.Load (aname);
2954 Assert.Fail ("#C3");
2955 } catch (FileLoadException) {
2958 aname = new AssemblyName ();
2959 aname.Name = "bug79522C";
2960 aname.CodeBase = assemblyFile;
2961 aname.Version = new Version (2, 4);
2963 AppDomain.CurrentDomain.Load (aname);
2965 // when the loaded assembly has a specific culture/publickey,
2966 // then that culture/publickey must be set if you set the
2967 // Version on the aname
2969 AppDomain.CurrentDomain.Load (aname);
2970 Assert.Fail ("#C4");
2971 } catch (FileLoadException) {
2975 aname = new AssemblyName ();
2976 aname.Name = "bug79522C";
2977 aname.CodeBase = assemblyFile;
2978 aname.CultureInfo = new CultureInfo ("nl-BE");
2979 aname.Version = new Version (2, 4);
2981 AppDomain.CurrentDomain.Load (aname);
2983 // if loaded assembly is signed, then the public key must be set
2985 AppDomain.CurrentDomain.Load (aname);
2986 Assert.Fail ("#C5");
2987 } catch (FileLoadException) {
2991 aname = new AssemblyName ();
2992 aname.Name = "bug79522C";
2993 aname.CodeBase = assemblyFile;
2994 aname.CultureInfo = new CultureInfo ("nl-BE");
2995 aname.SetPublicKey (publicKey);
2997 AppDomain.CurrentDomain.Load (aname);
2999 // if public key is set, then version must be set
3001 AppDomain.CurrentDomain.Load (aname);
3002 Assert.Fail ("#C6");
3003 } catch (FileLoadException) {
3007 aname = new AssemblyName ();
3008 aname.Name = "bug79522C";
3009 aname.CodeBase = assemblyFile;
3010 aname.CultureInfo = new CultureInfo ("nl-BE");
3012 AppDomain.CurrentDomain.Load (aname);
3015 AppDomain.CurrentDomain.Load (aname);
3016 Assert.Fail ("#C7");
3017 } catch (FileLoadException) {
3021 // if culture and version are set, then the version must match
3022 aname = new AssemblyName ();
3023 aname.Name = "bug79522C";
3024 aname.CodeBase = assemblyFile;
3025 aname.CultureInfo = new CultureInfo ("nl-BE");
3026 aname.SetPublicKey (publicKey);
3027 aname.Version = new Version (5, 6);
3029 AppDomain.CurrentDomain.Load (aname);
3030 Assert.Fail ("#C8");
3031 } catch (FileLoadException) {
3034 // publickey must match
3035 aname = new AssemblyName ();
3036 aname.Name = "bug79522C";
3037 aname.CodeBase = assemblyFile;
3038 aname.CultureInfo = new CultureInfo ("nl-BE");
3039 aname.Version = new Version (2, 4);
3040 aname.SetPublicKey (publicKey2);
3042 AppDomain.CurrentDomain.Load (aname);
3043 Assert.Fail ("#C9");
3045 } catch (SecurityException) {
3046 // Invalid assembly public key
3049 } catch (FileLoadException) {
3053 aname = new AssemblyName ();
3054 aname.Name = "bug79522C";
3055 aname.CodeBase = assemblyFile;
3056 aname.SetPublicKey (publicKey);
3057 aname.CultureInfo = new CultureInfo ("nl-BE");
3058 aname.Version = new Version (2, 4);
3059 AppDomain.CurrentDomain.Load (aname);
3062 [Test] // bug #79715
3063 public void Load_PartialVersion ()
3065 AppDomain ad = CreateTestDomain (tempDir, true);
3067 CrossDomainTester cdt = CreateCrossDomainTester (ad);
3069 AssemblyName aname = new AssemblyName ();
3070 aname.Name = "bug79715";
3071 aname.Version = new Version (1, 2, 3, 4);
3072 cdt.GenerateAssembly (aname, Path.Combine (tempDir, "bug79715.dll"));
3074 aname = new AssemblyName ();
3075 aname.Name = "bug79715";
3076 aname.Version = new Version (1, 2);
3077 Assert.IsTrue (cdt.AssertLoad (aname), "#A1");
3078 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#A2");
3080 aname = new AssemblyName ();
3081 aname.Name = "bug79715";
3082 aname.Version = new Version (1, 2, 3);
3083 Assert.IsTrue (cdt.AssertLoad (aname), "#B1");
3084 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#B2");
3086 aname = new AssemblyName ();
3087 aname.Name = "bug79715";
3088 aname.Version = new Version (1, 2, 3, 4);
3089 Assert.IsTrue (cdt.AssertLoad (aname), "#C1");
3090 Assert.IsTrue (cdt.AssertLoad (aname.FullName), "#C2");
3092 AppDomain.Unload (ad);
3097 [ExpectedException (typeof (ArgumentException))]
3098 public void Load_EmptyString ()
3100 AppDomain.CurrentDomain.Load ("");
3104 public void SetAppDomainPolicy ()
3106 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Null");
3107 ad.SetAppDomainPolicy (PolicyLevel.CreateAppDomainLevel ());
3112 [ExpectedException (typeof (ArgumentNullException))]
3113 public void SetAppDomainPolicy_Null ()
3115 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Null");
3116 ad.SetAppDomainPolicy (null);
3120 [ExpectedException (typeof (PolicyException))]
3121 public void SetAppDomainPolicy_Dual ()
3123 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Dual");
3124 PolicyLevel pl = PolicyLevel.CreateAppDomainLevel ();
3125 PermissionSet ps = new PermissionSet (PermissionState.Unrestricted);
3126 pl.RootCodeGroup.PolicyStatement = new PolicyStatement (ps);
3127 ad.SetAppDomainPolicy (pl);
3130 pl = PolicyLevel.CreateAppDomainLevel ();
3131 ps = new PermissionSet (PermissionState.None);
3132 pl.RootCodeGroup.PolicyStatement = new PolicyStatement (ps);
3133 ad.SetAppDomainPolicy (pl);
3137 [ExpectedException (typeof (AppDomainUnloadedException))]
3138 public void SetAppDomainPolicy_Unloaded ()
3140 ad = AppDomain.CreateDomain ("SetAppDomainPolicy_Unloaded");
3141 AppDomain.Unload (ad);
3142 ad.SetAppDomainPolicy (PolicyLevel.CreateAppDomainLevel ());
3146 [ExpectedException (typeof (ArgumentNullException))]
3147 public void GetData_Null ()
3149 AppDomain.CurrentDomain.GetData (null);
3153 public void SetData ()
3155 AppDomain.CurrentDomain.SetData ("data", "data");
3156 Assert.AreEqual ("data", AppDomain.CurrentDomain.GetData ("data"), "GetData");
3157 AppDomain.CurrentDomain.SetData ("data", null);
3158 Assert.IsNull (AppDomain.CurrentDomain.GetData ("data"), "GetData-Null");
3162 [ExpectedException (typeof (ArgumentNullException))]
3163 public void SetData_Null ()
3165 AppDomain.CurrentDomain.SetData (null, "data");
3170 public void ApplyPolicy ()
3172 ad = AppDomain.CreateDomain ("ApplyPolicy");
3173 string fullname = Assembly.GetExecutingAssembly ().FullName;
3174 string result = ad.ApplyPolicy (fullname);
3175 Assert.AreEqual (fullname, result, "ApplyPolicy");
3176 // doesn't even requires an assembly name
3177 Assert.AreEqual ("123", ad.ApplyPolicy ("123"), "Invalid FullName");
3181 [ExpectedException (typeof (ArgumentException))]
3182 public void ApplyPolicy_Empty ()
3184 ad = AppDomain.CreateDomain ("ApplyPolicy_Empty");
3185 ad.ApplyPolicy (String.Empty);
3189 [ExpectedException (typeof (ArgumentNullException))]
3190 public void ApplyPolicy_Null ()
3192 ad = AppDomain.CreateDomain ("ApplyPolicy_Null");
3193 ad.ApplyPolicy (null);
3197 public void DomainManager ()
3199 Assert.IsNull (AppDomain.CurrentDomain.DomainManager, "CurrentDomain.DomainManager");
3200 ad = AppDomain.CreateDomain ("DomainManager");
3201 Assert.IsNull (ad.DomainManager, "ad.DomainManager");
3205 public void IsDefaultAppDomain ()
3207 ad = AppDomain.CreateDomain ("ReflectionOnlyGetAssemblies");
3208 Assert.IsFalse (ad.IsDefaultAppDomain (), "IsDefaultAppDomain");
3209 // we have no public way to get the default appdomain
3213 public void ReflectionOnlyGetAssemblies ()
3215 ad = AppDomain.CreateDomain ("ReflectionOnlyGetAssemblies");
3216 Assembly [] a = ad.ReflectionOnlyGetAssemblies ();
3217 Assert.IsNotNull (a, "ReflectionOnlyGetAssemblies");
3218 Assert.AreEqual (0, a.Length, "Count");
3220 string assemblyFile = Path.Combine (tempDir, "bug499013.dll");
3221 AssemblyName aname = new AssemblyName ();
3222 aname.Name = "bug499013";
3223 aname.Version = new Version (2, 4);
3225 GenerateAssembly (aname, assemblyFile);
3227 Assembly.ReflectionOnlyLoadFrom (assemblyFile);
3228 foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies ())
3229 Assert.IsTrue (assembly.GetName ().Name != "bug499013");
3233 public void ReflectionOnlyAssemblyResolve ()
3235 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
3236 Assembly asm = Assembly.ReflectionOnlyLoad(Assembly.LoadWithPartialName("System").FullName);
3240 private static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args)
3242 return Assembly.ReflectionOnlyLoad(args.Name);
3246 private static AppDomain CreateTestDomain (string baseDirectory, bool assemblyResolver)
3248 AppDomainSetup setup = new AppDomainSetup ();
3249 setup.ApplicationBase = baseDirectory;
3250 setup.ApplicationName = "testdomain";
3251 return CreateTestDomain (setup, assemblyResolver);
3254 private static AppDomain CreateTestDomain (AppDomainSetup setup, bool assemblyResolver)
3256 AppDomain ad = AppDomain.CreateDomain ("testdomain",
3257 AppDomain.CurrentDomain.Evidence, setup);
3259 if (assemblyResolver) {
3260 Assembly ea = Assembly.GetExecutingAssembly ();
3261 ad.CreateInstanceFrom (ea.CodeBase,
3262 typeof (AssemblyResolveHandler).FullName,
3264 BindingFlags.Public | BindingFlags.Instance,
3266 new object [] { ea.Location, ea.FullName },
3267 CultureInfo.InvariantCulture,
3276 private static CrossDomainTester CreateCrossDomainTester (AppDomain domain)
3278 Type testerType = typeof (CrossDomainTester);
3279 return (CrossDomainTester) domain.CreateInstanceAndUnwrap (
3280 testerType.Assembly.FullName, testerType.FullName, false,
3281 BindingFlags.Public | BindingFlags.Instance, null, new object [0],
3282 CultureInfo.InvariantCulture, new object [0], null);
3285 private static void GenerateAssembly (AssemblyName aname, string path)
3287 AppDomain ad = CreateTestDomain (AppDomain.CurrentDomain.BaseDirectory,
3290 CrossDomainTester cdt = CreateCrossDomainTester (ad);
3291 cdt.GenerateAssembly (aname, path);
3293 AppDomain.Unload (ad);
3297 private bool RunningOnUnix {
3299 // check for Unix platforms - see FAQ for more details
3300 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
3301 int platform = (int) Environment.OSVersion.Platform;
3302 return ((platform == 4) || (platform == 128) || (platform == 6));
3306 private class CrossDomainTester : MarshalByRefObject
3308 public void GenerateAssembly (AssemblyName aname, string path)
3310 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
3311 aname, AssemblyBuilderAccess.Save, Path.GetDirectoryName (path));
3312 ab.Save (Path.GetFileName (path));
3315 public int AssemblyCount {
3317 return AppDomain.CurrentDomain.GetAssemblies ().Length;
3321 public string GetApplicationBase ()
3323 return AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
3326 public string GetConfigurationFile ()
3328 return AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
3331 public void Load (AssemblyName assemblyRef)
3333 AppDomain.CurrentDomain.Load (assemblyRef);
3336 public void LoadFrom (string assemblyFile)
3338 Assembly.LoadFrom (assemblyFile);
3341 public bool AssertLoad (AssemblyName assemblyRef)
3344 AppDomain.CurrentDomain.Load (assemblyRef);
3351 public bool AssertLoad (string assemblyString)
3354 AppDomain.CurrentDomain.Load (assemblyString);
3361 public bool AssertFileLoadException (AssemblyName assemblyRef)
3364 AppDomain.CurrentDomain.Load (assemblyRef);
3366 } catch (FileLoadException) {
3371 public bool AssertFileNotFoundException (AssemblyName assemblyRef)
3374 AppDomain.CurrentDomain.Load (assemblyRef);
3376 } catch (FileNotFoundException) {
3383 private class AssemblyResolveHandler
3385 public AssemblyResolveHandler (string assemblyFile, string assemblyName)
3387 _assemblyFile = assemblyFile;
3388 _assemblyName = assemblyName;
3390 AppDomain.CurrentDomain.AssemblyResolve +=
3391 new ResolveEventHandler (ResolveAssembly);
3394 private Assembly ResolveAssembly (object sender, ResolveEventArgs args)
3396 if (args.Name == _assemblyName)
3397 return Assembly.LoadFrom (_assemblyFile);
3402 private readonly string _assemblyFile;
3403 private readonly string _assemblyName;
3406 static byte [] keyPair = {
3407 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41,
3408 0x32, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x3D, 0xBD,
3409 0x72, 0x08, 0xC6, 0x2B, 0x0E, 0xA8, 0xC1, 0xC0, 0x58, 0x07, 0x2B,
3410 0x63, 0x5F, 0x7C, 0x9A, 0xBD, 0xCB, 0x22, 0xDB, 0x20, 0xB2, 0xA9,
3411 0xDA, 0xDA, 0xEF, 0xE8, 0x00, 0x64, 0x2F, 0x5D, 0x8D, 0xEB, 0x78,
3412 0x02, 0xF7, 0xA5, 0x36, 0x77, 0x28, 0xD7, 0x55, 0x8D, 0x14, 0x68,
3413 0xDB, 0xEB, 0x24, 0x09, 0xD0, 0x2B, 0x13, 0x1B, 0x92, 0x6E, 0x2E,
3414 0x59, 0x54, 0x4A, 0xAC, 0x18, 0xCF, 0xC9, 0x09, 0x02, 0x3F, 0x4F,
3415 0xA8, 0x3E, 0x94, 0x00, 0x1F, 0xC2, 0xF1, 0x1A, 0x27, 0x47, 0x7D,
3416 0x10, 0x84, 0xF5, 0x14, 0xB8, 0x61, 0x62, 0x1A, 0x0C, 0x66, 0xAB,
3417 0xD2, 0x4C, 0x4B, 0x9F, 0xC9, 0x0F, 0x3C, 0xD8, 0x92, 0x0F, 0xF5,
3418 0xFF, 0xCE, 0xD7, 0x6E, 0x5C, 0x6F, 0xB1, 0xF5, 0x7D, 0xD3, 0x56,
3419 0xF9, 0x67, 0x27, 0xA4, 0xA5, 0x48, 0x5B, 0x07, 0x93, 0x44, 0x00,
3420 0x4A, 0xF8, 0xFF, 0xA4, 0xCB, 0x73, 0xC0, 0x6A, 0x62, 0xB4, 0xB7,
3421 0xC8, 0x92, 0x58, 0x87, 0xCD, 0x07, 0x0C, 0x7D, 0x6C, 0xC1, 0x4A,
3422 0xFC, 0x82, 0x57, 0x0E, 0x43, 0x85, 0x09, 0x75, 0x98, 0x51, 0xBB,
3423 0x35, 0xF5, 0x64, 0x83, 0xC7, 0x79, 0x89, 0x5C, 0x55, 0x36, 0x66,
3424 0xAB, 0x27, 0xA4, 0xD9, 0xD4, 0x7E, 0x6B, 0x67, 0x64, 0xC1, 0x54,
3425 0x4E, 0x37, 0xF1, 0x4E, 0xCA, 0xB3, 0xE5, 0x63, 0x91, 0x57, 0x12,
3426 0x14, 0xA6, 0xEA, 0x8F, 0x8F, 0x2B, 0xFE, 0xF3, 0xE9, 0x16, 0x08,
3427 0x2B, 0x86, 0xBC, 0x26, 0x0D, 0xD0, 0xC6, 0xC4, 0x1A, 0x72, 0x43,
3428 0x76, 0xDC, 0xFF, 0x28, 0x52, 0xA1, 0xDE, 0x8D, 0xFA, 0xD5, 0x1F,
3429 0x0B, 0xB5, 0x4F, 0xAF, 0x06, 0x79, 0x11, 0xEE, 0xA8, 0xEC, 0xD3,
3430 0x74, 0x55, 0xA2, 0x80, 0xFC, 0xF8, 0xD9, 0x50, 0x69, 0x48, 0x01,
3431 0xC2, 0x5A, 0x04, 0x56, 0xB4, 0x3E, 0x24, 0x32, 0x20, 0xB5, 0x2C,
3432 0xDE, 0xBB, 0xBD, 0x13, 0xFD, 0x13, 0xF7, 0x03, 0x3E, 0xE3, 0x37,
3433 0x84, 0x74, 0xE7, 0xD0, 0x5E, 0x9E, 0xB6, 0x26, 0xAE, 0x6E, 0xB0,
3434 0x55, 0x6A, 0x52, 0x63, 0x6F, 0x5A, 0x9D, 0xF2, 0x67, 0xD6, 0x61,
3435 0x4F, 0x7A, 0x45, 0xEE, 0x5C, 0x3D, 0x2B, 0x7C, 0xB2, 0x40, 0x79,
3436 0x54, 0x84, 0xD1, 0xBE, 0x61, 0x3E, 0x5E, 0xD6, 0x18, 0x8E, 0x14,
3437 0x98, 0xFC, 0x35, 0xBF, 0x5F, 0x1A, 0x20, 0x2E, 0x1A, 0xD8, 0xFF,
3438 0xC4, 0x6B, 0xC0, 0xC9, 0x7D, 0x06, 0xEF, 0x09, 0xF9, 0xF3, 0x69,
3439 0xFC, 0xBC, 0xA2, 0xE6, 0x80, 0x22, 0xB9, 0x79, 0x7E, 0xEF, 0x57,
3440 0x9F, 0x49, 0xE1, 0xBC, 0x0D, 0xB6, 0xA1, 0xFE, 0x8D, 0xBC, 0xBB,
3441 0xA3, 0x05, 0x02, 0x6B, 0x04, 0x45, 0xF7, 0x5D, 0xEE, 0x43, 0x06,
3442 0xD6, 0x9C, 0x94, 0x48, 0x1A, 0x0B, 0x9C, 0xBC, 0xB4, 0x4E, 0x93,
3443 0x60, 0x87, 0xCD, 0x58, 0xD6, 0x9A, 0x39, 0xA6, 0xC0, 0x7F, 0x8E,
3444 0xFF, 0x25, 0xC1, 0xD7, 0x2C, 0xF6, 0xF4, 0x6F, 0x24, 0x52, 0x0B,
3445 0x39, 0x42, 0x1B, 0x0D, 0x04, 0xC1, 0x93, 0x2A, 0x19, 0x1C, 0xF0,
3446 0xB1, 0x9B, 0xC1, 0x24, 0x6D, 0x1B, 0x0B, 0xDA, 0x1C, 0x8B, 0x72,
3447 0x48, 0xF0, 0x3E, 0x52, 0xBF, 0x0A, 0x84, 0x3A, 0x9B, 0xC8, 0x6D,
3448 0x13, 0x1E, 0x72, 0xF4, 0x46, 0x93, 0x88, 0x1A, 0x5F, 0x4C, 0x3C,
3449 0xE5, 0x9D, 0x6E, 0xBB, 0x4E, 0xDD, 0x5D, 0x1F, 0x11, 0x40, 0xF4,
3450 0xD7, 0xAF, 0xB3, 0xAB, 0x9A, 0x99, 0x15, 0xF0, 0xDC, 0xAA, 0xFF,
3451 0x9F, 0x2D, 0x9E, 0x56, 0x4F, 0x35, 0x5B, 0xBA, 0x06, 0x99, 0xEA,
3452 0xC6, 0xB4, 0x48, 0x51, 0x17, 0x1E, 0xD1, 0x95, 0x84, 0x81, 0x18,
3453 0xC0, 0xF1, 0x71, 0xDE, 0x44, 0x42, 0x02, 0x06, 0xAC, 0x0E, 0xA8,
3454 0xE2, 0xF3, 0x1F, 0x96, 0x1F, 0xBE, 0xB6, 0x1F, 0xB5, 0x3E, 0xF6,
3455 0x81, 0x05, 0x20, 0xFA, 0x2E, 0x40, 0x2E, 0x4D, 0xA0, 0x0E, 0xDA,
3456 0x42, 0x9C, 0x05, 0xAA, 0x9E, 0xAF, 0x5C, 0xF7, 0x3A, 0x3F, 0xBB,
3457 0x91, 0x73, 0x45, 0x27, 0xA8, 0xA2, 0x07, 0x4A, 0xEF, 0x59, 0x1E,
3458 0x97, 0x9D, 0xE0, 0x30, 0x5A, 0x83, 0xCE, 0x1E, 0x57, 0x32, 0x89,
3459 0x43, 0x41, 0x28, 0x7D, 0x14, 0x8D, 0x8B, 0x41, 0x1A, 0x56, 0x76,
3460 0x43, 0xDB, 0x64, 0x86, 0x41, 0x64, 0x8D, 0x4C, 0x91, 0x83, 0x4E,
3463 static byte [] publicKey2 = {
3464 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41,
3465 0x32, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7F, 0x7C,
3466 0xEA, 0x4A, 0x28, 0x33, 0xD8, 0x3C, 0x86, 0x90, 0x86, 0x91, 0x11,
3467 0xBB, 0x30, 0x0D, 0x3D, 0x69, 0x04, 0x4C, 0x48, 0xF5, 0x4F, 0xE7,
3468 0x64, 0xA5, 0x82, 0x72, 0x5A, 0x92, 0xC4, 0x3D, 0xC5, 0x90, 0x93,
3469 0x41, 0xC9, 0x1D, 0x34, 0x16, 0x72, 0x2B, 0x85, 0xC1, 0xF3, 0x99,
3470 0x62, 0x07, 0x32, 0x98, 0xB7, 0xE4, 0xFA, 0x75, 0x81, 0x8D, 0x08,
3471 0xB9, 0xFD, 0xDB, 0x00, 0x25, 0x30, 0xC4, 0x89, 0x13, 0xB6, 0x43,
3472 0xE8, 0xCC, 0xBE, 0x03, 0x2E, 0x1A, 0x6A, 0x4D, 0x36, 0xB1, 0xEB,
3473 0x49, 0x26, 0x6C, 0xAB, 0xC4, 0x29, 0xD7, 0x8F, 0x25, 0x11, 0xA4,
3474 0x7C, 0x81, 0x61, 0x97, 0xCB, 0x44, 0x2D, 0x80, 0x49, 0x93, 0x48,
3475 0xA7, 0xC9, 0xAB, 0xDB, 0xCF, 0xA3, 0x34, 0xCB, 0x6B, 0x86, 0xE0,
3476 0x4D, 0x27, 0xFC, 0xA7, 0x4F, 0x36, 0xCA, 0x13, 0x42, 0xD3, 0x83,
3477 0xC4, 0x06, 0x6E, 0x12, 0xE0, 0xA1, 0x3D, 0x9F, 0xA9, 0xEC, 0xD1,
3478 0xC6, 0x08, 0x1B, 0x3D, 0xF5, 0xDB, 0x4C, 0xD4, 0xF0, 0x2C, 0xAA,
3479 0xFC, 0xBA, 0x18, 0x6F, 0x48, 0x7E, 0xB9, 0x47, 0x68, 0x2E, 0xF6,
3480 0x1E, 0x67, 0x1C, 0x7E, 0x0A, 0xCE, 0x10, 0x07, 0xC0, 0x0C, 0xAD,
3481 0x5E, 0xC1, 0x53, 0x70, 0xD5, 0xE7, 0x25, 0xCA, 0x37, 0x5E, 0x49,
3482 0x59, 0xD0, 0x67, 0x2A, 0xBE, 0x92, 0x36, 0x86, 0x8A, 0xBF, 0x3E,
3483 0x17, 0x04, 0xFB, 0x1F, 0x46, 0xC8, 0x10, 0x5C, 0x93, 0x02, 0x43,
3484 0x14, 0x96, 0x6A, 0xD9, 0x87, 0x17, 0x62, 0x7D, 0x3A, 0x45, 0xBE,
3485 0x35, 0xDE, 0x75, 0x0B, 0x2A, 0xCE, 0x7D, 0xF3, 0x19, 0x85, 0x4B,
3486 0x0D, 0x6F, 0x8D, 0x15, 0xA3, 0x60, 0x61, 0x28, 0x55, 0x46, 0xCE,
3487 0x78, 0x31, 0x04, 0x18, 0x3C, 0x56, 0x4A, 0x3F, 0xA4, 0xC9, 0xB1,
3488 0x41, 0xED, 0x22, 0x80, 0xA1, 0xB3, 0xE2, 0xC7, 0x1B, 0x62, 0x85,
3489 0xE4, 0x81, 0x39, 0xCB, 0x1F, 0x95, 0xCC, 0x61, 0x61, 0xDF, 0xDE,
3490 0xF3, 0x05, 0x68, 0xB9, 0x7D, 0x4F, 0xFF, 0xF3, 0xC0, 0x0A, 0x25,
3491 0x62, 0xD9, 0x8A, 0x8A, 0x9E, 0x99, 0x0B, 0xFB, 0x85, 0x27, 0x8D,
3492 0xF6, 0xD4, 0xE1, 0xB9, 0xDE, 0xB4, 0x16, 0xBD, 0xDF, 0x6A, 0x25,
3493 0x9C, 0xAC, 0xCD, 0x91, 0xF7, 0xCB, 0xC1, 0x81, 0x22, 0x0D, 0xF4,
3494 0x7E, 0xEC, 0x0C, 0x84, 0x13, 0x5A, 0x74, 0x59, 0x3F, 0x3E, 0x61,
3495 0x00, 0xD6, 0xB5, 0x4A, 0xA1, 0x04, 0xB5, 0xA7, 0x1C, 0x29, 0xD0,
3496 0xE1, 0x11, 0x19, 0xD7, 0x80, 0x5C, 0xEE, 0x08, 0x15, 0xEB, 0xC9,
3497 0xA8, 0x98, 0xF5, 0xA0, 0xF0, 0x92, 0x2A, 0xB0, 0xD3, 0xC7, 0x8C,
3498 0x8D, 0xBB, 0x88, 0x96, 0x4F, 0x18, 0xF0, 0x8A, 0xF9, 0x31, 0x9E,
3499 0x44, 0x94, 0x75, 0x6F, 0x78, 0x04, 0x10, 0xEC, 0xF3, 0xB0, 0xCE,
3500 0xA0, 0xBE, 0x7B, 0x25, 0xE1, 0xF7, 0x8A, 0xA8, 0xD4, 0x63, 0xC2,
3501 0x65, 0x47, 0xCC, 0x5C, 0xED, 0x7D, 0x8B, 0x07, 0x4D, 0x76, 0x29,
3502 0x53, 0xAC, 0x27, 0x8F, 0x5D, 0x78, 0x56, 0xFA, 0x99, 0x45, 0xA2,
3503 0xCC, 0x65, 0xC4, 0x54, 0x13, 0x9F, 0x38, 0x41, 0x7A, 0x61, 0x0E,
3504 0x0D, 0x34, 0xBC, 0x11, 0xAF, 0xE2, 0xF1, 0x8B, 0xFA, 0x2B, 0x54,
3505 0x6C, 0xA3, 0x6C, 0x09, 0x1F, 0x0B, 0x43, 0x9B, 0x07, 0x95, 0x83,
3506 0x3F, 0x97, 0x99, 0x89, 0xF5, 0x51, 0x41, 0xF6, 0x8E, 0x5D, 0xEF,
3507 0x6D, 0x24, 0x71, 0x41, 0x7A, 0xAF, 0xBE, 0x81, 0x71, 0xAB, 0x76,
3508 0x2F, 0x1A, 0x5A, 0xBA, 0xF3, 0xA6, 0x65, 0x7A, 0x80, 0x50, 0xCE,
3509 0x23, 0xC3, 0xC7, 0x53, 0xB0, 0x7C, 0x97, 0x77, 0x27, 0x70, 0x98,
3510 0xAE, 0xB5, 0x24, 0x66, 0xE1, 0x60, 0x39, 0x41, 0xDA, 0x54, 0x01,
3511 0x64, 0xFB, 0x10, 0x33, 0xCE, 0x8B, 0xBE, 0x27, 0xD4, 0x21, 0x57,
3512 0xCC, 0x0F, 0x1A, 0xC1, 0x3D, 0xF3, 0xCC, 0x39, 0xF0, 0x2F, 0xAE,
3513 0xF1, 0xC0, 0xCD, 0x3B, 0x23, 0x87, 0x49, 0x7E, 0x40, 0x32, 0x6A,
3514 0xD3, 0x96, 0x4A, 0xE5, 0x5E, 0x6E, 0x26, 0xFD, 0x8A, 0xCF, 0x7E,
3515 0xFC, 0x37, 0xDE, 0x39, 0x0C, 0x53, 0x81, 0x75, 0x08, 0xAF, 0x6B,
3516 0x39, 0x6C, 0xFB, 0xC9, 0x79, 0xC0, 0x9B, 0x5F, 0x34, 0x86, 0xB2,
3517 0xDE, 0xC4, 0x19, 0x84, 0x5F, 0x0E, 0xED, 0x9B, 0xB8, 0xD3, 0x17,
3520 static byte [] publicKey = {
3521 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00,
3522 0x00, 0x06, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53,
3523 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x3d,
3524 0xbd, 0x72, 0x08, 0xc6, 0x2b, 0x0e, 0xa8, 0xc1, 0xc0, 0x58, 0x07,
3525 0x2b, 0x63, 0x5f, 0x7c, 0x9a, 0xbd, 0xcb, 0x22, 0xdb, 0x20, 0xb2,
3526 0xa9, 0xda, 0xda, 0xef, 0xe8, 0x00, 0x64, 0x2f, 0x5d, 0x8d, 0xeb,
3527 0x78, 0x02, 0xf7, 0xa5, 0x36, 0x77, 0x28, 0xd7, 0x55, 0x8d, 0x14,
3528 0x68, 0xdb, 0xeb, 0x24, 0x09, 0xd0, 0x2b, 0x13, 0x1b, 0x92, 0x6e,
3529 0x2e, 0x59, 0x54, 0x4a, 0xac, 0x18, 0xcf, 0xc9, 0x09, 0x02, 0x3f,
3530 0x4f, 0xa8, 0x3e, 0x94, 0x00, 0x1f, 0xc2, 0xf1, 0x1a, 0x27, 0x47,
3531 0x7d, 0x10, 0x84, 0xf5, 0x14, 0xb8, 0x61, 0x62, 0x1a, 0x0c, 0x66,
3532 0xab, 0xd2, 0x4c, 0x4b, 0x9f, 0xc9, 0x0f, 0x3c, 0xd8, 0x92, 0x0f,
3533 0xf5, 0xff, 0xce, 0xd7, 0x6e, 0x5c, 0x6f, 0xb1, 0xf5, 0x7d, 0xd3,
3534 0x56, 0xf9, 0x67, 0x27, 0xa4, 0xa5, 0x48, 0x5b, 0x07, 0x93, 0x44,
3535 0x00, 0x4a, 0xf8, 0xff, 0xa4, 0xcb };
3537 static byte [] pk_token = { 0xce, 0x52, 0x76, 0xd8, 0x68, 0x7e, 0Xc6, 0xdc };