Re: [Mono-dev] Initialization of array of enum - trying to not use RuntimeInternals.InitializeArray
Hello John, There is a known bug in the Microsoft CLR on the x86_64 platform with regards to initializing an array whose members are enum values (http://connect.microsoft.com/VisualStudio/feedback/details/635365/runtimehelpers-initializearray-fails-on-64b-framework). It appears that the Microsoft csc compiler somehow works around this whereas gmcs does not. For example, the following compiled with gmcs does not run on the Microsoft CLR on x86_64 (it throws an exception in InitializeArray) but does when compiled with csc: class Program { enum e { A, B, C, D, E }; static void Main() { e[] array = new e[] { e.A, e.B, e.C, e.D, e.E }; } } I appreciate this is apparently a bug with the Microsoft 64 bit CLR rather than mono, but at the moment Microsoft's csc appears to work around this where mono does not. Is there a way of telling gmcs to not use a call to InitializeArray when instantiating arrays of enums (instead doing something like: e[] array = new e[5]; e[0] = e.A; e[1] = e.B; ... for the above example), or if not would there be any support for adding this (e.g. via an optional command line flag to gmcs)? Expanding the initialization is the easiest option how to workaround this .net bug. Because the scope of the bug is quite limited and easy to workaround I don't think it's work adding special handling for it. Microsoft already fixed the issue but I am not sure whether there is a hotfix available for .NET 2.0 Marek ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Initialization of array of enum - trying to not use RuntimeInternals.InitializeArray
On 7/23/2012 9:53 AM, Marek Safar wrote: Expanding the initialization is the easiest option how to workaround this .net bug. Because the scope of the bug is quite limited and easy to workaround I don't think it's work adding special handling for it. Microsoft already fixed the issue but I am not sure whether there is a hotfix available for .NET 2.0 I've tried it using .NET 2.0 and 4.0. It works fine on 32-bit, but both versions fail with ArgumentException on x64. (All the patches from Windows Update are applied.) It however works with .NET 4.5 RC on x64. (That is indeed the next release after the the date of their comment on connect.) Note that the workaround is simple: Not to use InitializeArray for enum arrays. Kornel ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Initialization of array of enum - trying to not use RuntimeInternals.InitializeArray
There is a known bug in the Microsoft CLR on the x86_64 platform with regards to initializing an array whose members are enum values (http://connect.microsoft.com/VisualStudio/feedback/details/635365/runtimehelpers-initializearray-fails-on-64b-framework). It appears that the Microsoft csc compiler somehow works around this whereas gmcs does not. For example, the following compiled with gmcs does not run on the Microsoft CLR on x86_64 (it throws an exception in InitializeArray) but does when compiled with csc: class Program { enum e { A, B, C, D, E }; static void Main() { e[] array = new e[] { e.A, e.B, e.C, e.D, e.E }; } } I appreciate this is apparently a bug with the Microsoft 64 bit CLR rather than mono, but at the moment Microsoft's csc appears to work around this where mono does not. Is there a way of telling gmcs to not use a call to InitializeArray when instantiating arrays of enums (instead doing something like: e[] array = new e[5]; e[0] = e.A; e[1] = e.B; ... for the above example), or if not would there be any support for adding this (e.g. via an optional command line flag to gmcs)? Regards, John. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list