MonoGame-WinFormsControls
MonoGame-WinFormsControls copied to clipboard
Null reference
When debugging anything that uses the MGWinForms.GraphicsDeviceService on the void CreateDevice at line 71(_device = new GraphicsDevice(adapter, profile, pp);). Do you get the same results? Thanks!
Yup, me too :(
It looks like it's still a problem. I've done enough reading to know it was fixed in 3.2 of Monogame, but sometime between then and the current 3.6 it broke again and I don't know enough to fix it myself.
here's where they fixed it before: https://github.com/MonoGame/MonoGame/issues/2586
Going a little deeper, I get a NullReferenceException at the line:
102 var displayIndex = Sdl.Display.GetWindowDisplayIndex(SdlGameWindow.Instance.Handle);
Call Stack:
MonoGame.Framework.dll!Microsoft.Xna.Framework.Graphics.GraphicsAdapter.CurrentDisplayMode.get() Line 102
MonoGame.Framework.dll!Microsoft.Xna.Framework.Graphics.GraphicsDevice.DisplayMode.get() Line 625
MonoGame.Framework.dll!Microsoft.Xna.Framework.Graphics.GraphicsDevice.Setup() Line 233
MonoGame.Framework.dll!Microsoft.Xna.Framework.Graphics.GraphicsDevice.GraphicsDevice(Microsoft.Xna.Framework.Graphics.GraphicsAdapter adapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile graphicsProfile, Microsoft.Xna.Framework.Graphics.PresentationParameters presentationParameters) Line 214
MGWinForms.dll!MGWinForms.GraphicsDeviceService.CreateDevice(System.IntPtr windowHandle, int width, int height) Line 64
MGWinForms.dll!MGWinForms.GraphicsDeviceService.AddRef(System.IntPtr windowHandle, int width, int height) Line 30
MGWinForms.dll!MGWinForms.GraphicsDeviceControl.OnCreateControl() Line 54
[External Code]
ExampleGame.exe!ExampleGame.Program.Main() Line 16
[External Code]
I tried building Monogame from the source, but that didn't help. I tried using the Direct X version, and that runs, but the control is black. Doing that with the embedded game example, it still registers the boxes hitting the bottom of the screen, so I assume the game or whatever loop is still running and even passing information to the WinForms portion of the program.
I know you haven't touched this thing for a couple years, but if you could take a look it would be appreciated. Thank you.