[Mono-bugs] [Bug 36158][Nor] New - System.NullReferenceException caught when executing Type.TypeInitializer.Invoke
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
29 Dec 2002 10:20:37 -0000
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by karaznie@acn.waw.pl.
http://bugzilla.ximian.com/show_bug.cgi?id=36158
--- shadow/36158 Sun Dec 29 05:20:37 2002
+++ shadow/36158.tmp.512 Sun Dec 29 05:20:37 2002
@@ -0,0 +1,96 @@
+Bug#: 36158
+Product: Mono/Runtime
+Version: unspecified
+OS:
+OS Details: Linux 2.4.20-686
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: karaznie@acn.waw.pl
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: System.NullReferenceException caught when executing Type.TypeInitializer.Invoke
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+System.NullReferenceException caught when trying
+instantiate type using Invoke method on TypeInitializer
+with mono-17:
+
+Code snipet:
+
+$ cat Foo.cs
+
+
+using System;
+
+public class Bar {
+
+ public Bar() {
+ System.Console.WriteLine( "Bar.Bar()" );
+ }
+
+}
+
+
+public class Foo {
+
+ public static void Main( String[] args ) {
+
+ // instantiating class directly
+ Bar bar = new Bar();
+
+ // instantiating class using reflection and TypeInitializer
+ // regarding to MSDN - we use empty parameters
+ // to invoke "default" ctor.
+ Object[] parameters = new Object[0];
+ bar.GetType().TypeInitializer.Invoke( parameters );
+
+ }
+
+}
+
+$ mono Foo.exe
+ Bar.Bar()
+
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in <0x00096> 00 .Foo:Main (string[])
+
+
+
+Steps to reproduce the problem:
+1.
+2.
+3.
+
+Actual Results:
+
+$ mono Foo.exe
+ Bar.Bar()
+
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in <0x00096> 00 .Foo:Main (string[])
+
+
+Expected Results:
+
+$ mono Foo.exe
+ Bar.Bar()
+ Bar.Bar()
+
+How often does this happen?
+
+always running Type.TypeInitializer.Invoke() method
+
+Additional Information:
+
+mono-17 release.