[Mono-bugs] [Bug 80936][Wis] New - Casting error using PrincipalPermission attribute
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Feb 22 12:51:17 EST 2007
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by ben at joldersma.org.
http://bugzilla.ximian.com/show_bug.cgi?id=80936
--- shadow/80936 2007-02-22 12:51:17.000000000 -0500
+++ shadow/80936.tmp.15463 2007-02-22 12:51:17.000000000 -0500
@@ -0,0 +1,76 @@
+Bug#: 80936
+Product: Mono: Runtime
+Version: 1.2
+OS:
+OS Details: Ubuntu Edgy/Eft
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: ben at joldersma.org
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Casting error using PrincipalPermission attribute
+
+Description of Problem:
+
+I've taken the sample from Sebastien's blog entry here:
+
+http://pages.infinit.net/ctech/200502.html
+
+and tried to compile it verbatim, and an error is thrown when I turn the
+security manager on. I've since slimmed down the code to the below to
+reproduce the error.
+
+Steps to reproduce the problem:
+1. Run this code sample with --security option on mono:
+
+using System;
+using System.Security.Permissions;
+
+public class Program {
+
+ [PrincipalPermission (SecurityAction.Demand, Name="root")]
+ public void Execute ()
+ {
+ Console.WriteLine ("Welcome {0}", Environment.UserName);
+ }
+
+ static void Main ()
+ {
+ new Program ().Execute ();
+ }
+}
+
+Actual Results:
+
+Unhandled Exception: System.InvalidCastException: Cannot cast from source
+type to destination type.
+ at System.Security.PermissionSet.Demand () [0x0004c] in
+/tmp/scratch/BUILD/mono-1.2.3/mcs/class/corlib/System.Security/PermissionSet.cs:230
+
+ at System.Security.SecurityManager.InternalDemand (IntPtr permissions,
+Int32 length) [0x00008] in
+/tmp/scratch/BUILD/mono-1.2.3/mcs/class/corlib/System.Security/SecurityManager.cs:777
+
+ at Program.Execute () [0x00000] in
+/home/ben/workspaces/Sandbox/casTest/Main.cs:9
+ at Program.Main () [0x00000] in
+/home/ben/workspaces/Sandbox/casTest/Main.cs:14
+
+
+Expected Results:
+
+"Welcome, root"
+
+How often does this happen?
+
+Every time.
+
+Additional Information:
+
+NA
More information about the mono-bugs
mailing list