How To Solve "<MyGame> has had an error and needed to close. Send an error report."

Last post 04-07-2008, 6:40 PM by Nick Gravelyn. 0 replies.
Sort Posts: Previous Next
  •  04-07-2008, 6:40 PM

    How To Solve "<MyGame> has had an error and needed to close. Send an error report."

    A frequent problem found after distributing an XNA Game Studio game to another computer is double clicking the EXE only to get a window with this sort of message in it:
    "<MyGame> has had an error and needed to close. Send an error report."

    This message really could mean a couple of things:
    1. You didn't actually run the redists described in the dependency FAQ: http://forums.xna.com/thread/9924.aspx. First thing you should do is run all of those redists. Don't assume they are installed; run the redists and they will install if needed.
    2. There is an uncaught exception in your code. 

    To find out if there is an uncaught exception, follow these steps:
    1. First, add a reference to System.Windows.Forms in your game project.
    2. Next, in your Main method (found in Program.cs by default), wrap the entire code in a try/catch block that looks like this:
    public static void Main()
    {
    try
    {
    using (Game1 game = new Game1())
    game.Run();
    }

    catch (Exception e)
    {
    System.Windows.Forms.MessageBox.Show(e.ToString());
    }
    }


    Run your game again. You should see a window pop up with the exception details printed. Now you can use this information to fix the uncaught exceptions in your game. For more information on exceptions and try/catch blocks, see these sites:

    http://www.csharp-station.com/Tutorials/Lesson15.aspx
    http://msdn2.microsoft.com/en-us/library/0yd65esw.aspx
    http://msdn2.microsoft.com/en-us/library/dszsf989(VS.71).aspx
    http://msdn2.microsoft.com/en-us/library/system.exception.aspx

    If, however, you run that code and don't see a window pop up with that information, that indicates you did not actually perform step 1 of installing the dependencies. Please use the link above to install the dependencies and run the game again.


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback