[SOLVED] NullReferenceException when creating instance of Game class

i’m retaking a old project that uses XNA 4.0 framework and Visual Studio 2013, now that i can get it work on Monogame and Visual Studio 2015 i got this error, i have read a similar thread error here but it was a problem with a Static Method, this is right after runing the game in Program.cs and Game1.cs files

Exception thrown: ‘System.NullReferenceException’ in MonoGame.Framework.dll
Additional information: {“Object reference not set to an instance of an object”}


Can you show us the stack trace given by the exception?

en Microsoft.Xna.Framework.MetroGamePlatform…ctor(Game game)
en Microsoft.Xna.Framework.GamePlatform.PlatformCreate(Game game)
en Microsoft.Xna.Framework.Game…ctor()
en Drive.Game1…ctor() en C:\Users\odiseo\Documents\Visual Studio 2015\Projects\Drive\Drive\Game1.cs:línea 55
en Drive.Program.Main() en C:\Users\odiseo\Documents\Visual Studio 2015\Projects\Drive\Drive\Program.cs:línea 17
en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()

Sounds like a Win 8 project.

Maybe you want to just try a MonoGame DirectX Windows project first.

I have solved it, in my case I just had to add the library (Monogame.FrameWork) reference manually with the browse option.

1 Like

Thank you Ulisses_Lopez :slight_smile: