简体   繁体   中英

NullReferenceException on creating an instance of an inheriting class

I am writing my own game engine in XNA and started to port it into MonoGame so that I can put it on Android/iOS/Windows 8. For some reason I am getting a null reference exception when the main create a new game object. So the code that allocates the object is:

    static void Main(string[] args)
    {
        //game g = new game();
        using (game game = new game())
        {
            game.Run();
        }
    }

and the error is as

    public lesaEngine()

which is the base constructor for the game object.

the inheritance is just as always

    class lesaEngine : Microsoft.Xna.Framework.Game
    class game : lesaEngine

Not sure whats going on here. It works normally under normal XNA. I am using Visual Studio 2012 for the port.

Did you create a new Win8 monogame project? if so the entry point should look more like this

#if !NETFX_CORE 
  using (MyGame game = new MyGame()) 
  { 
      game.Run();
  } 
#endif 
#if NETFX_CORE 
  var factory = newMonoGame.Framework.GameFrameworkViewSource<MyGame>();
  Windows.ApplicationModel.Core.CoreApplication.Run(factory); 
#endif } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM