Bug 52608 - Mono.CSharp.InternalErrorException when a specific assembly is added as reference
Summary: Mono.CSharp.InternalErrorException when a specific assembly is added as refer...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.8.0 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2017-02-17 19:27 UTC by Lex Li
Modified: 2017-02-22 10:57 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
trial.zip (828.98 KB, application/zip)
2017-02-20 17:51 UTC, Lex Li
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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.

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.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Lex Li 2017-02-17 19:27:50 UTC
In Visual Studio for Mac latest build, create a new console application, and add the three assemblies from https://www.dropbox.com/home/Public/installers/sharpsnmppro?preview=trial.zip

Main method is as below,

                public static void Main(string[] args)
		{
			Console.WriteLine("Hello World!");
			Lextm.SharpSnmpLib.Counter32 counter = new Lextm.SharpSnmpLib.Counter32(0);
		}

Compile this project triggers C# compiler exception (while these assemblies work fine for .NET Framework projects on Windows),


Building Solution: testsnmp (Debug|x86)
Build started 2/17/2017 2:14:55 PM.
__________________________________________________
Project "/Users/lextm/Projects/testsnmp/testsnmp/testsnmp.csproj" (Build target(s)):

Target GenerateTargetFrameworkMonikerAttribute:
  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target CoreCompile:
    /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5/mcs.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/mscorlib.dll /reference:/Users/lextm/Downloads/trial/SharpSnmpLib.Full.dll /reference:/Users/lextm/Downloads/trial/SharpSnmpLib.Portable.dll /reference:/Users/lextm/Downloads/trial/SharpSnmpPro.Mib.Trial.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/System.Core.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/System.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Collections.Concurrent.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Collections.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ComponentModel.Annotations.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ComponentModel.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ComponentModel.EventBasedAsync.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Diagnostics.Contracts.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Diagnostics.Debug.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Diagnostics.Tools.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Diagnostics.Tracing.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Dynamic.Runtime.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Globalization.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.IO.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Linq.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Linq.Expressions.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Linq.Parallel.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Linq.Queryable.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Net.NetworkInformation.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Net.Primitives.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Net.Requests.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ObjectModel.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.Emit.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.Emit.ILGeneration.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.Emit.Lightweight.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.Extensions.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Reflection.Primitives.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Resources.ResourceManager.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.Extensions.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.InteropServices.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.InteropServices.WindowsRuntime.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.Numerics.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.Serialization.Json.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.Serialization.Primitives.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Runtime.Serialization.Xml.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Security.Principal.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ServiceModel.Duplex.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ServiceModel.Http.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ServiceModel.NetTcp.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ServiceModel.Primitives.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.ServiceModel.Security.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Text.Encoding.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Text.Encoding.Extensions.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Text.RegularExpressions.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Threading.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Threading.Tasks.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Threading.Tasks.Parallel.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Threading.Timer.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Xml.ReaderWriter.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Xml.XDocument.dll /reference:/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5-api/Facades/System.Xml.XmlSerializer.dll /debug+ /debug:full /optimize- /out:obj/x86/Debug/testsnmp.exe /subsystemversion:6.00 /target:exe /utf8output Program.cs Properties/AssemblyInfo.cs "/var/folders/t2/9q2v939x6g55k3h2jjrx4n7w0000gn/T/.NETFramework,Version=v4.5.1.AssemblyAttributes.cs"
    
    Unhandled Exception:
    Mono.CSharp.InternalErrorException: Failed to import assembly `SharpSnmpPro.Mib.Trial, Version=1.2.21231.4, Culture=neutral, PublicKeyToken=4c00852d3788e005' ---> System.ArgumentNullException: Value cannot be null.
    Parameter name: name
      at IKVM.Reflection.TypeName..ctor (System.String ns, System.String name) [0x00006] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.TypeDefImpl.get_TypeName () [0x00000] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x0005d] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1[T] list) [0x00000] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Module.GetTypes () [0x00006] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x0000d] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00008] in <6c6b2f38a076460eacf227054ff6f99a>:0 
       --- End of inner exception stack trace ---
      at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00054] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x0009a] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.Driver.Compile () [0x0022e] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.Driver.Main (System.String[] args) [0x00052] in <6c6b2f38a076460eacf227054ff6f99a>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: Failed to import assembly `SharpSnmpPro.Mib.Trial, Version=1.2.21231.4, Culture=neutral, PublicKeyToken=4c00852d3788e005' ---> System.ArgumentNullException: Value cannot be null.
    Parameter name: name
      at IKVM.Reflection.TypeName..ctor (System.String ns, System.String name) [0x00006] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.TypeDefImpl.get_TypeName () [0x00000] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x0005d] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1[T] list) [0x00000] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Module.GetTypes () [0x00006] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x0000d] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00008] in <6c6b2f38a076460eacf227054ff6f99a>:0 
       --- End of inner exception stack trace ---
      at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00054] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x0009a] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.Driver.Compile () [0x0022e] in <6c6b2f38a076460eacf227054ff6f99a>:0 
      at Mono.CSharp.Driver.Main (System.String[] args) [0x00052] in <6c6b2f38a076460eacf227054ff6f99a>:0 
    /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.CSharp.Core.targets(67,5): error MSB6006: "mcs.exe" exited with code 1.
Done building target "CoreCompile" in project "testsnmp.csproj" -- FAILED.

Done building project "testsnmp.csproj" -- FAILED.

Build FAILED.

/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.CSharp.Core.targets(67,5): error MSB6006: "mcs.exe" exited with code 1.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.19

---------------------- Done ----------------------

Build: 1 error, 0 warnings
Comment 1 Lex Li 2017-02-17 19:29:48 UTC
The test console application is from Others -> .NET -> Console Project template.
Comment 2 Marek Safar 2017-02-20 17:49:23 UTC
I cannot access the repro, could you attach it?
Comment 3 Lex Li 2017-02-20 17:51:39 UTC
Created attachment 19883 [details]
trial.zip
Comment 4 Marek Safar 2017-02-22 10:57:45 UTC
Fixed in master