Bugzilla – Bug 313419
Embeded mono weirdness.
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by tambet@ximian.com 2003-12-19 14:30:48 MST ---- 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:11 MST ---- 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 https://bugzilla.novell.com/show_bug.cgi?id=MONO53893 *** Unknown operating system unknown. Setting to default OS "Other". This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"