Bug 7565 - TypeLoadException when running Scala.NET compiler
Summary: TypeLoadException when running Scala.NET compiler
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: Other Other
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-10-01 09:55 UTC by Konrad Kruczyński
Modified: 2017-07-13 00:15 UTC (History)
2 users (show)

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

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 Konrad Kruczyński 2012-10-01 09:55:46 UTC
Description of Problem:
Cannot run Scala.NET compiler on Mono 2.11.5 (e5e80ee).

Steps to reproduce the problem:
1. Download compiler from https://github.com/downloads/magarciaEPFL/scaladotnet/scala-bin-20120310-ee51b6e1b1.zip
2. Run mono scalacompiler.exe


Actual Results:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for scala.tools.nsc.Main$ ---> System.TypeInitializationException: An exception was thrown by the type initializer for scala.tools.nsc.Properties$ ---> System.TypeInitializationException: An exception was thrown by the type initializer for scala.Predef$ ---> System.TypeInitializationException: An exception was thrown by the type initializer for scala.package$ ---> System.TypeInitializationException: An exception was thrown by the type initializer for scala.collection.Traversable$ ---> System.TypeInitializationException: An exception was thrown by the type initializer for java.lang.Throwable ---> System.TypeInitializationException: An exception was thrown by the type initializer for Object ---> System.TypeLoadException: A type load exception has occurred.



Expected Results:
Normal run

How often does this happen? 
Always

Additional Information:
Comment 1 Konrad Kruczyński 2012-10-01 10:02:19 UTC
If one removes mscorlib.dll and other framework stuff (don't know why it is there), the error changes to:

Unhandled Exception:
System.TypeLoadException: Could not load type 'scala.reflect.internal.FatalError' from assembly 'scalacompiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at scala.tools.nsc.settings.MutableSettings+OutputSetting..ctor (scala.tools.nsc.settings.MutableSettings $outer, scala.tools.nsc.settings.OutputDirs outputDirs, System.String default) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.MutableSettings.OutputSetting (scala.tools.nsc.settings.OutputDirs outputDirs, System.String default) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.ScalaSettings$class.$init$ (scala.tools.nsc.settings.MutableSettings $this) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.MutableSettings..ctor (Function1 errorFn) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Settings..ctor (Function1 errorFn) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Driver.process (System.String[] args) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Main$.main (System.String[] args) [0x00000] in <filename unknown>:0 
  at <Module>.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'scala.reflect.internal.FatalError' from assembly 'scalacompiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at scala.tools.nsc.settings.MutableSettings+OutputSetting..ctor (scala.tools.nsc.settings.MutableSettings $outer, scala.tools.nsc.settings.OutputDirs outputDirs, System.String default) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.MutableSettings.OutputSetting (scala.tools.nsc.settings.OutputDirs outputDirs, System.String default) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.ScalaSettings$class.$init$ (scala.tools.nsc.settings.MutableSettings $this) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.settings.MutableSettings..ctor (Function1 errorFn) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Settings..ctor (Function1 errorFn) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Driver.process (System.String[] args) [0x00000] in <filename unknown>:0 
  at scala.tools.nsc.Main$.main (System.String[] args) [0x00000] in <filename unknown>:0 
  at <Module>.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 2 Konrad Kruczyński 2012-10-03 06:49:35 UTC
I think the key issue is here:
Mono: no implementation for interface method scala.Equals::Equals(object) in class scala.reflect.internal.FatalError. In fact this object does not implement the given method of interface. It however works on .NET. Should the implementation of Equals given in every object be taken as the implicit implementation of this interface? The C# compiler works with that but I'm not sure what is the underlying IL machinery.
Comment 3 Rodrigo Kumpera 2012-11-30 15:31:20 UTC
Working on it. I need first to reduce this to a manageable test case.
Comment 4 Rodrigo Kumpera 2017-07-13 00:15:38 UTC
I can reproduce with 5.2 but no longer with master.

On master it fails with:
```
System.TypeInitializationException: The type initializer for 'IKVM.Internal.Tracer' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at IKVM.Internal.Tracer.Init () [0x000a1] in <d724adcb68844c15b5cc1dd71c65eb73>:0 
  at IKVM.Internal.Tracer..cctor () [0x0008c] in <d724adcb68844c15b5cc1dd71c65eb73>:0 
````