Created attachment 8808 [details]
When trying to compile a program using a dll that csc and ILDASM/ILASM consider valid the mono C# compiler encounters an internal compiler error.
The problem appears to be that in the dll's IL representation it is assigning an int16 value to a unit16 static literal and mono does not like this. I do not have access to the original source for the dll and was unable to determine what kind of source or compilation is required to generate the IL that mono errors out on.
public class Bar
public const int FIELD = Foo.CONSTANT;
B.il - IL for the attached B.dll
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.1
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v2.0.50727
.assembly extern mscorlib
.hash algorithm 0x00008004
.class public abstract auto ansi TypeLib.Foo
// Mono doesn't like int16 here
// If I change it to uint16 the error goes away.
.field public static literal uint16 CONSTANT = int16(0xFFFF)
Command Lines - See attached for copy of B.dll
$ /opt/pkg/mono-3.8.0/bin/mcs /t:library /r:B.dll Reproducer.cs
Reproducer.cs(4,36): error CS0584: Internal compiler error: Unexpected error when loading type `TypeLib.Foo'
error CS0133: The expression being assigned to `Bar.FIELD' must be constant
Compilation failed: 2 error(s), 0 warnings
$ csc /t:library /r:B.dll Reproducer.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.18408
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
Edward Moriarty | Junior Engineer
Coverity | The Leader in Development Testing
Fixed in master
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on GitHub
to continue tracking issues. Bugzilla will remain available for
reference in read-only mode. We will continue to work on open Bugzilla
bugs, copy them to the new locations as needed for follow-up, and add
the new items under Related Links.
Create a new report for Bug 24675 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Our sincere thanks to everyone who has contributed on this bug tracker
over the years. Thanks also for your understanding as we make these
adjustments and improvements for the future.