[Mono-bugs] [Bug 52375][Nor] New - Embeded mono weirdness.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 5 Feb 2004 07:04:11 -0500 (EST)


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 vargaz@freemail.hu.

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

--- shadow/52375	2004-02-05 07:04:11.000000000 -0500
+++ shadow/52375.tmp.23449	2004-02-05 07:04:11.000000000 -0500
@@ -0,0 +1,73 @@
+Bug#: 52375
+Product: Mono/Runtime
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: RESOLVED   
+Resolution: DUPLICATE
+Severity: Unknown
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: tambet@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Embeded mono weirdness.
+
+I have simple C file which does something like:
+
+domain = mono_jit_init ("domain");
+assembly = mono_domain_assembly_open (domain, "hello.dll");
+class = mono_class_from_name (assembly->image, "", "Bar");
+mo = mono_object_new (domain, class);
+mdesc = mono_method_desc_new (":blah", FALSE);
+method = mono_method_desc_search_in_class (mdesc, class);
+mono_runtime_invoke (method, mo, NULL, NULL);
+
+And hello.cs which has:
+
+using System;
+
+class Bar {
+	public static void blah() {
+		String a = "4";
+		int b = 4;
+		Console.WriteLine("blah {0}", a);
+		Console.WriteLine("blah {0}", b);
+	}
+}
+
+When I run the C program, I get trace:
+
+blah 4
+ 
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in <0x00016> System.Globalization.NumberFormatInfo:get_CurrentInfo ()
+in <0x00066> System.Globalization.NumberFormatInfo:GetInstance
+(System.IFormatProvider)
+in <0x00014> System.Int32:ToString (string,System.IFormatProvider)
+in <0x0022b> System.String:FormatHelper
+(System.Text.StringBuilder,System.IFormatProvider,string,object[])
+in <0x0003f> System.String:Format (System.IFormatProvider,string,object[])
+in <0x00053> System.String:Format (string,object)
+in <0x00016> System.IO.TextWriter:Write (string,object)
+in <0x00038> System.IO.SynchronizedWriter:Write (string,object)
+in <0x0001d> System.Console:WriteLine (string,object)
+in <0x00054> .Bar:blah ()
+
+
+However, if I change last WriteLine to 
+Console.WriteLine("blah {0}", b.ToSting());
+
+It works.
+
+------- Additional Comments From vargaz@freemail.hu  2004-02-05 07:04 -------
+You need to call mono_thread_attach (domain) before calling 
+mono_runtime_invoke so the runtime can create its per-thread data
+structures.
+
+
+*** This bug has been marked as a duplicate of 53893 ***