3 using System.Security.Permissions;
4 using System.Security.Principal;
5 using System.Threading;
9 // Note: this should also fail if you replace "me" with your username
11 [PrincipalPermission (SecurityAction.LinkDemand, Name="me")]
12 static int LinkDemand ()
14 Console.WriteLine ("*1* [this should not print]");
20 Console.WriteLine ("[this should not print - as JIT will reject the LinkDemand]");
22 GenericIdentity identity = new GenericIdentity ("me");
23 string[] roles = new string [1] { "mono hacker" };
24 Thread.CurrentPrincipal = new GenericPrincipal (identity, roles);
30 static int Main (string[] args)
35 catch (SecurityException se) {
36 Console.WriteLine ("*0* Expected SecurityException\n{0}", se);
40 Console.WriteLine ("*2* Unexpected Exception\n{0}", e);