[Mono-dev] anonymous delegates, gmcs, and Microsoft.NET permissions checking problems

Marek Safar marek.safar at seznam.cz
Fri Aug 24 04:34:15 EDT 2007


Hi Avery,

Please fill a bug report into http://bugzilla.ximian.com

Thanks
Marek

> I'm using a copy of gmcs built on Linux from yesterday's mono svn
> trunk.  The program listed below works fine when run under Linux, but
> gives the following exception when run in Windows:
>
> Unhandled Exception: System.MethodAccessException:
> <>c__CompilerGenerated0.<Main>c__1()
>    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 1.2.5.0 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).
>
> Thoughts?
>
> Have fun,
>
> Avery
>
>
> using System;
>
> public static class MyClass
> {
>     public delegate void Foo();
>
>     public static void Main()
>     {
> 	Console.WriteLine("hello");
> 	Foo x = delegate() {};
> 	x();
> 	Console.WriteLine("goodbye");
>     }
> }
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>   




More information about the Mono-devel-list mailing list