2005-02-08 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mono / tests / cas / linkdemand / pinvoke2.cs
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Security;
4
5 namespace System {
6
7         public class Program {
8
9                 [DllImport ("libc", SetLastError=true)]
10                 public static extern uint getuid ();
11
12                 // this attribute has NO effect on LinkDemand!
13                 [SuppressUnmanagedCodeSecurity]
14                 static int Test ()
15                 {
16                         try {
17                                 uint uid = getuid ();
18                                 Console.WriteLine ("*0* getuid: {0}", uid);
19                                 return 0;
20                         }
21                         catch (SecurityException se) {
22                                 Console.WriteLine ("*1* Expected SecurityException\n{0}", se);
23                                 return 1;
24                         }
25                         catch (Exception e) {
26                                 Console.WriteLine ("*2* Unexpected exception\n{0}", e);
27                                 return 2;
28                         }
29                 }
30
31                 static int Main ()
32                 {
33                         return Test ();
34                 }
35         }
36 }