[Mono-dev] Strange enum issue

Neale Ferguson neale at sinenomine.net
Tue Mar 10 22:51:49 UTC 2015

I changed the read_enum_value function to do the swaps and rebuilt. Now the Console.Error.WriteLine() in WindowsRuntimeProjection() produces:

WindowsRuntimeProjection - System_Runtime System_Runtime_InteropServices_WindowsRuntime Count

Which is what is expected. However, I’m still crashing with NRE later in the build:

Unhandled Exception:

Mono.CSharp.InternalErrorException: Microsoft.Win32/RegistryKeyPermissionCheck.cs(31,21): Microsoft.Win32 ---> Mono.CSharp.InternalErrorException: Microsoft.Win32/RegistryKeyPermissionCheck.cs(33,14): Microsoft.Win32.RegistryKeyPermissionCheck ---> System.TypeInitializationException: An exception was thrown by the type initializer for IKVM.Reflection.WindowsRuntimeProjection ---> System.NullReferenceException: Object reference not set to an instance of an object

  at IKVM.Reflection.TypeName.GetHashCode ()<0x2000800c398 + 0x001bc> in <filename unknown>:0

Hi Neale,

ves_icall_System_Enum_GetEnumValuesAndNames.3229: 0. field=System_Runtime
ves_icall_System_Enum_GetEnumValuesAndNames.3229: 1.
field=System_Runtime_InteropServices_WindowsRuntime value=16777216
ves_icall_System_Enum_GetEnumValuesAndNames.3229: 2.
field=System_ObjectModel value=33554432
ves_icall_System_Enum_GetEnumValuesAndNames.3229: 3.
field=System_Runtime_WindowsRuntime value=50331648
ves_icall_System_Enum_GetEnumValuesAndNames.3229: 4.
field=System_Runtime_WindowsRuntime_UI_Xaml value=67108864
ves_icall_System_Enum_GetEnumValuesAndNames.3229: 5. field=Count

Note 16777216 is hex 10000000. Now to find out how that value gets placed
there and to do some byte swapping on it.

You are probably looking for https://github.com/mono/mono/blob/master/mono/metadata/icall.c#L2961. There has been no endian changes there for years but due to different codepath this is now hit more often before.


P.S. I am wondering if it would be worth it to create a routine or more in
icall.c to do the byte swap for 2/4/8 byte integers rather than coding up
clumsy stuff in managed code.

On 3/10/15, 3:01 PM, "Robert Jordan" <robertj at gmx.net<mailto:robertj at gmx.net>> wrote:

>There was a recent commit which added MS' reference source Enum
>support to Mono:
>Maybe it's an endian-related issue.

Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com<mailto:Mono-devel-list at lists.ximian.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20150310/7fc13f2a/attachment.html>

More information about the Mono-devel-list mailing list