updating to the latest module.
[mono.git] / mono / tests / cas / linkdemand / aptc2.cs
1 using System;
2 using System.Reflection;
3 //using System.Runtime.CompilerServices;
4 using System.Security;
5
6 using Mono.Test;
7
8 public class Program {
9
10         static bool IsSigned ()
11         {
12                 return (Assembly.GetExecutingAssembly ().GetName ().GetPublicKey () != null);
13         }
14
15         static int Main ()
16         {
17                 try {
18                         // aptclib.dll is strongnamed and DOESN'T have [AllowPartiallyTrustedCallers]
19                         // so this call will work ONLY IF this assembly IS strongnamed
20                         string s = AptcLibrary.Hello ("World");
21                         int ec = IsSigned () ? 0 : 1;
22                         Console.WriteLine ("*{0}* AptcLibrary: {1}", ec, s);
23                         return ec;
24                 }
25                 catch (SecurityException se) {
26                         int ec = IsSigned () ? 1 : 0;
27                         Console.WriteLine ("*{0}* Expected SecurityException\n{1}", ec, se);
28                         return ec;
29                 }
30                 catch (Exception e) {
31                         Console.WriteLine ("*2* Unexpected exception\n{0}", e);
32                         return 2;
33                 }
34         }
35 }