Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem: TypeInitializationException when instantiating Game object

$
0
0
I've been working on my XNA game project for a week or so now, and trying to run the project today I'm getting a TypeInitializationException when trying to instantiate my Game class. The code is modified somewhat from the default XNA template, but even changing it back to the default results in the same error. The code:

static class Program
    {
        public static GameMain game;

        static void Main(string[] args)
        {
            game = new GameMain(); //Error happens here
            game.Run();
        }
    }



Breakpoints placed in first line of the constructor in GameMain are never hit. I've been searching for hours for a solution, and have reinstalled XNA and C# Express several times. There are two Inner Exceptions listed in the error. The first states "Use the "new" keyword to create an object instance" and the second states "Check to determine if the object is null before calling the method". I have tried moving the project to a different machine with a fresh XNA install and got the same error. I have tried creating a new XNA project and running it, and it builds and runs fine, displaying the default empty window with a blue background. Does anybody know what might be causing this?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>