[Mono-devel-list] bug w/ initializer?

Herscovici, Avi AHerscovici at Empirix.com
Tue Jul 8 13:56:09 EDT 2003


Have a simple example for you guys that causes a weird exception in mono
(runs fine in .net).  I found it while working on my project.  The exception
is thrown only when the array is of this size or bigger.  If you cut out a
row my program hangs, and if you cut out two rows from the initial value,
then it returns the correct value.  Here is the code and the exception:


// --------------------------------- code
using System;

namespace TestInitialize {

public class testinit {

static string[,] temp =	{{"1", "2", "3"},
			 {"4", "5", "6"},
			 {"7", "8", "9"},
			 {"10", "11", "12"},
			 {"13", "14", "15"},
			 {"16", "17", "18"},
			 {"19", "20", "21"},
			 {"22", "23", "24"},
			 {"25", "26", "27"},
			 {"28", "29", "30"},
			 {"31", "32", "33"},  // if you get rid of the this
and the next line program will work fine
			 {"34", "35", "36"}   // if you get rid of this line
program will hang
			};

public testinit() {
 // nothing
}


static void Main() {
test();
}

static public void test() {
Console.WriteLine("Temp should not be nothing: " + temp[0,0]);
}

}
}


// ------ exception

Unhandled Exception: System.TypeInitializationException: An exception was
thrown by the type initializer for TestInitialize.testinit --->
System.NullReferenceException: A null value was found where an object
instance was required
in <0x00037> 00 TestInitialize.testinit:.cctor ()
--- End of inner exception stack trace ---




More information about the Mono-devel-list mailing list