0

I have a problem integrating MonoGame into an existing WindowsPhone8.0 project.
Everything seems to work fine, but when is start the app it's crashing with NullPointerException in MonoGame Framework.

StackTrace:

at MonoGame.Framework.WindowsPhone.WindowsPhoneGameWindow..ctor(Game game)
at MonoGame.Framework.WindowsPhone.WindowsPhoneGamePlatform..ctor(Game game)
at Microsoft.Xna.Framework.GamePlatform.PlatformCreate(Game game)
at Microsoft.Xna.Framework.Game..ctor()
at myApp.Game1..ctor()
at myApp.myPage..ctor()

EDIT: I have also tried that: link

M.D.
  • 273
  • 1
  • 5
  • 18

1 Answers1

0

Based on the stack trace your myPage constructor goes somewhat like this:

_game = new Game1();

The Windows Phone project template, however, does it this way:

_game = XamlGame<Game1>.Create("", this);

The latter version does lots of initialization, for example stores a reference to the XAML page for framework use. The first version crashes because the said initialization is not done, and tries to access null page.

Petri Laarne
  • 421
  • 3
  • 7
  • But now i can not start the game. It crashes when i call "Run()"-Method. NullPointerException at Microsoft.Xna.Framework.Graphics.GraphicsDevice.UpdateDevice(Device device, DeviceContext context) – M.D. Jun 25 '16 at 14:44
  • The template does not call `Run()` at all. I'm not able to verify it right now, but does the game start without the call? – Petri Laarne Jun 26 '16 at 17:58