Bugzilla – Bug 324299
Static .cctors and Main()
Last modified: 2007-10-05 12:34:59 UTC
---- Reported by martin@ximian.com 2007-05-14 16:19:56 MST ---- We currently have a problem with the way how the debugger breaks in Main: If you're debugging an application where the class containing Main() contains a static .cctor, you might run into problems. This applies especially if your application is using System.Configuration in that .cctor or if the class has static fields which are using System.Configuration. I'm currently working on a fix, but that'll require some larger changes in the way how the debugger handles Main(). At the moment, the debugger gets a notification from the JIT before calling mono_runtime_run_main() - this notification triggers a JIT compilation of Main() and inserts a breakpoint on it. This is neccessary because the debugger may need to insert breakpoints when reaching Main(). Unfortunately, this is causing problems if that compilation needs to run any static .cctors. I'll change the code to not trigger the compilation but instead wait till we reach Main() by normal flow of execution - don't know yet how exactly this will be archived. ---- Additional Comments From martin@ximian.com 2007-05-14 16:25:45 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO81615 has been marked as a duplicate of this bug. *** ---- Additional Comments From martin@ximian.com 2007-05-14 16:26:28 MST ---- A simple test case is this: ====== using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; class X { static X () { Console.WriteLine ("TEST!"); NameValueCollection config = ConfigurationSettings.AppSettings; Console.WriteLine ("TEST #2"); } static void Main () { Console.WriteLine ("Hello World!"); } } ===== This will crash when run inside mdb. Unknown operating system unknown. Setting to default OS "Other".
Fixed long ago.