merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / mono / tests / cas / linkdemand / cas9.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4
5 [assembly: SecurityPermission (SecurityAction.RequestRefuse, ControlPrincipal=true)]
6
7 public delegate int MyReturnCode (int rc);
8
9 public class Program {
10
11         [SecurityPermission (SecurityAction.LinkDemand, ControlPrincipal=true)]
12         static public int StaticTest (int rc)
13         {
14                 Console.WriteLine ("*1* Static delegate call expected to fail!");
15                 return rc;
16         }
17
18         static int Test ()
19         {
20                 MyReturnCode rc = new MyReturnCode (StaticTest);
21                 return rc (1);
22         }
23
24         static int Main ()
25         {
26                 try {
27                         return Test ();
28                 }
29                 catch (SecurityException se) {
30                         Console.WriteLine ("*0* Expected SecurityException\n{0}", se);
31                         return 0;
32                 }
33                 catch (Exception e) {
34                         Console.WriteLine ("*2* Unexpected Exception\n{0}", e);
35                         return 2;
36                 }
37         }
38 }