[Mono-bugs] [Bug 82571][Wis] New - anonymous delegates, gmcs, and Microsoft.NET permissions checking problems

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Aug 24 10:18:58 EDT 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 apenwarr at gmail.com.


--- shadow/82571	2007-08-24 10:18:58.000000000 -0400
+++ shadow/82571.tmp.18315	2007-08-24 10:18:58.000000000 -0400
@@ -0,0 +1,59 @@
+Bug#: 82571
+Product: Mono: Compilers
+Version: unspecified
+OS Details: Compiling on Ubuntu/Dapper; running on Windows XP + .NET 2.0
+Status: NEW   
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: apenwarr at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: anonymous delegates, gmcs, and Microsoft.NET permissions checking problems
+Using mono from svn://anonsvn.mono-project.com/source/trunk/mcs@84648
+The program listed below works fine when run compiled with latest gmcs and
+run under Linux, but gives the following exception when run in Windows:
+Unhandled Exception: System.MethodAccessException:
+  at MyClass.Main()
+However, compiling it with Microsoft's csc.exe from .NET 2.0 results
+in a binary that works in both Linux (mono) and Windows (.NET).
+The command line I'm using to compile (under Cygwin) is:
+  /c/WINDOWS/Microsoft.NET/Framework/v2.0.50727/csc.exe bug.cs
+or in Linux:
+  gmcs bug.cs
+I also have gmcs (release) version installed via
+Ubuntu/dapper.  Compiling and running the binary with that version
+works fine in both Linux and Windows.
+Commenting out the two lines of code relating to the delegate in the
+sample program also makes it work fine.  The crash occurs even if I
+comment out the line calling the delegate (except I get an unused
+variable warning, of course).
+using System;
+public static class MyClass
+   public delegate void Foo();
+   public static void Main()
+   {
+       Console.WriteLine("hello");
+       Foo x = delegate() {};
+       x();
+       Console.WriteLine("goodbye");
+   }

More information about the mono-bugs mailing list