[Mono-list] mint mcs.exe exception

Andreas Jellinghaus aj@dungeon.inka.de
Tue, 26 Feb 2002 18:58:39 +0100


hi.

i don't know how to read this, can anyone give me a hint?
can i do something usefull without knowing mono/mint/mcs interna?

regards, andreas

$ LD_LIBRARY_PATH=../lib/ ../bin/mint ../bin/mcs.exe page30.cs 
Unhandled exception System.NullReferenceException A null value was found
where an object instance was required.
#0: 0x0000e callvirt   in Mono.CSharp.MyEventBuilder::SetAddOnMethod ([0x8209888] )
#1: 0x0017c callvirt   in Mono.CSharp.Event::Define ([0x81762b8] )
#2: 0x00024 callvirt   in Mono.CSharp.TypeContainer::DefineMembers ([0x81aeae0] [0x81fbff8] )
#3: 0x0012b call       in Mono.CSharp.TypeContainer::Define ([0x8135100])
#4: 0x0009c callvirt   in Mono.CSharp.RootContext::PopulateTypes ()
#5: 0x0088d call       in Mono.CSharp.Driver::MainDriver ([0x80e7338] )
#6: 0x00001 call       in Mono.CSharp.Driver::Main ([0x80e7338] )

the code is c#/ecma 334 , page 30:

using System;

class MyClass
{
	public MyClass() {
		Console.WriteLine("Instance constructor");
	}
	public MyClass(int value) {
		MyField = value;
		Console.WriteLine("Instance constructor");
	}
	~MyClass() {
		Console.WriteLine("Destructor");
	}

	public const int MyConst = 12;
	
	public int MyField = 34;

	public void MyMethod() {
		Console.WriteLine("MyClass.MyMethod");
	}

	public int MyProperty {
		get {
			return MyField;
		}
		set {
			MyField = value;
		}
	}

	public int this[int index] {
		get {
			return 0;
		}
		set {
			Console.WriteLine("this[{0}] = {1}", index, value);
		}
	}

	public event EventHandler MyEvent;

	public static MyClass operator+(MyClass a, MyClass b) {
		return new MyClass(a.MyField + b.MyField);
	}

	internal class MyNestedClass
	{ }
}

class Test
{
	static void Main() {
		// Instance constructor usage
		MyClass a = new MyClass();
		MyClass b = new MyClass(123);

		// Constant usage
		Console.WriteLine("MyConst = {0}", MyClass.MyConst);

		// Field usage
		a.MyField++;
		Console.WriteLine("a.MyField = {0}", a.MyField);

		// Method usage
		a.MyMethod();

		// Property usage
		a.MyProperty++;
		Console.WriteLine("a.MyProperty = {0}", a.MyProperty);

		// Indexer usage
		a[3] = a[1] = a[2];
		Console.WriteLine("a[3] = {0}", a[3]);

		// Event usage
		a.MyEvent += new EventHandler(MyHandler);

		// Overloaded operator usage;
		MyClass c = a + b;
	}

	static void MyHandler(object sender, EventArgs e) {
		Console.WriteLine("Test.MyHandler");
	}

	internal class MyNestedClass
	{ }
}