Alternatives to Winforms for Exception Handling?

Hello all,

Winforms is giving me grief.When I package my game with mkbundle it works on Linux, but I get this error on Mac when my exception-handling dialogs (made with winforms) try to initialize:

System.TypeInitializationException: The type initializer for
'System.Drawing.GDIPlus' threw an exception. --->
at(wrapper managed-to-native)

I need to get this working, or find a replacement.My winform dialogs aren’t complex, but the richtextbox on them allows the user to select and copy the stack trace to clipboard, something I’ve had trouble replicating elsewhere.They’re also capable of displaying (on windows at least) exceptions which prevent the OpenGL window from opening, which is why I can’t just spritebatch it to the main game window.

Any help?

If the objective is just to get exception text to the user you could.
Write it to a text file then open it.

using System.IO
File.WriteAllText(fullFilePath, text);

Then directly open that text file to display to the user.

using System.Diagnostics;

Basically something like this sorry this is just super old code its ugly.

        /// <summary>
        /// WriteExceptionStack
        /// </summary>
        public static void WriteStackFramesToFile(string errmsg, int numberOfFramesToTrace)
            string log_tempstring = "\n";
            log_tempstring += ("\n Exception Thrown");
            log_tempstring += ("\n _______________________________________________________");
            log_tempstring += ("\n " + errmsg);
            log_tempstring += ("\n _______________________________________________________");
            log_tempstring += ("\n StackTrace As Follows \n");
                // Create a StackTrace that captures filename,
                // linepieces number and column information.
                StackTrace st = new StackTrace(1, true);
                int count = st.FrameCount;
                if (numberOfFramesToTrace > count) { numberOfFramesToTrace = count; }
                for (int i = 0; i < numberOfFramesToTrace; i++)
                    StackFrame sf = st.GetFrame(i);

                    log_tempstring += " \n  stack # " + i.ToString();
                    log_tempstring += "  File: " + Path.GetFileNameWithoutExtension( sf.GetFileName() ); 
                    log_tempstring += "  Method: " + sf.GetMethod().ToString(); 
                    log_tempstring += "  Line: " + sf.GetFileLineNumber().ToString(); 
                    log_tempstring += "  Column: " + sf.GetFileColumnNumber().ToString(); 
                    // output the full stack frame
                throw new Exception();
            catch (Exception e)
                string fullpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErrorLog.txt");
                File.WriteAllText(fullpath, log_tempstring);
                throw e;

Text File Output…

     Exception Thrown
     We threw this on purpose to get the stack frames
     StackTrace As Follows 
      stack # 0  File: Game1  Method: Void Update(Microsoft.Xna.Framework.GameTime)  Line: 66  Column: 13 
      stack # 1  File:   Method: Void DoUpdate(Microsoft.Xna.Framework.GameTime)  Line: 0  Column: 0 
      stack # 2  File:   Method: Void Run(Microsoft.Xna.Framework.GameRunBehavior)  Line: 0  Column: 0 
      stack # 3  File: Program  Method: Void Main()  Line: 17  Column: 17

Thanks for the suggestion, willmotil. I already stream write a crashlog after the dialog, and I tried to open it as an alternative if raising the dialog failed. Unfortunately, our test mac managed to throw exceptions from within the try catch block, so I don’t even know what’s real anymore.

Looking into other solutions, I learned about and tried downloading the Gtk Sharp GUI library. ( Unfortunately, the library is 32 bit. I’d rather not go back to building my game in 32-bit: too many Memory Fragmentation issues.

Am still looking for a solution…

Maybe look into Eto.Forms