[Mono-bugs] [Bug 80435][Nor] New - NRE in MonoArrayMethod.ToString

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jan 3 05:10:22 EST 2007


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 rolfkvinge at ya.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80435

--- shadow/80435	2007-01-03 05:10:22.000000000 -0500
+++ shadow/80435.tmp.24224	2007-01-03 05:10:22.000000000 -0500
@@ -0,0 +1,79 @@
+Bug#: 80435
+Product: Mono: Class Libraries
+Version: 1.0
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: rolfkvinge at ya.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: NRE in MonoArrayMethod.ToString
+
+The following code produces a NRE:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+
+class vbnc_bugs
+{
+	static void Main ()
+	{
+		AssemblyBuilderAccess access = 
+AssemblyBuilderAccess.RunAndSave;
+		TypeAttributes attribs = TypeAttributes.Public;
+
+		AssemblyName name = new AssemblyName ("a");
+		AssemblyBuilder assembly = 
+AppDomain.CurrentDomain.DefineDynamicAssembly (name, access);
+
+		ModuleBuilder module = assembly.DefineDynamicModule ("m", 
+"test.dll");
+
+		Type [] myArrayClass = new Type [1];
+		Type [] parameterTypes = { typeof (Array) };
+		MethodInfo myMethodInfo = module.GetArrayMethod 
+(myArrayClass.GetType (), "Sort", CallingConventions.Standard,
+									
+		 null, parameterTypes);
+		Console.WriteLine(myMethodInfo.ToString ());
+	}
+}
+
+
+
+
+Result:
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+  at System.Reflection.MonoArrayMethod.ToString () [0x00048] in /mono/head/
+mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs:133
+  at vbnc_bugs.Main () [0x00000]
+
+
+The following patch worked for vbnc, but I don't know if it's correct or 
+not:
+
+--- MonoArrayMethod.cs  (revision 69875)
++++ MonoArrayMethod.cs  (working copy)
+@@ -130,7 +130,10 @@
+                                        parms = parms + ", ";
+                                parms = parms + p [i].ParameterType.Name;
+                        }
+-                       return ReturnType.Name+" "+Name+"("+parms+")";
++                       if (ReturnType != null)
++                               return 
+ReturnType.Name+" "+Name+"("+parms+")";
++                       else
++                               return "void ("+parms+")";
+                }
+        }
+ }


More information about the mono-bugs mailing list