Bug 11773 - Compiler as a service broken in Mono 3.0.9 (osx package)
Summary: Compiler as a service broken in Mono 3.0.9 (osx package)
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-04-13 21:05 UTC by Jonathan Shore
Modified: 2013-04-14 12:08 UTC (History)
1 user (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 Jonathan Shore 2013-04-13 21:05:10 UTC
I have been trying to uses Mono.CSharp to compile C# code at run time with mono 3.0.9.  I am having problems creating object instances for any class defined without the compiler-as-a-service environment.  This problem is easily reproduced with the C# repl (csharp command line tool):

csharp> class A 
      > {
      >    public string Name { get; set; }
      > }

csharp> new A();

Mono.CSharp.InternalErrorException: (1,1): <InteractiveExpressionClass>.Host(ref object) ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.Parameter.ApplyAttributes (System.Reflection.Emit.MethodBuilder mb, System.Reflection.Emit.ConstructorBuilder cb, Int32 index, Mono.CSharp.PredefinedAttributes pa) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ParametersCompiled.ApplyAttributes (IMemberContext mc, System.Reflection.MethodBase builder) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.CompileBlock (Mono.CSharp.Class host, Mono.CSharp.Undo undo, Mono.CSharp.Report Report) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Compile (System.String input, Mono.CSharp.CompiledMethod& compiled) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00000] in <filename unknown>:0 
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename unknown>:0
Comment 1 Marek Safar 2013-04-14 12:08:54 UTC
You need to use Mono 3.0.10. Unfortunately 3.0.9 has broken repl.