MonoGame Winforms Error

Hi! I’ve recently started working on my tools for MonoGame using WinForms. I’ve downloaded the sample for XNA (http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_1) and I’ve ported them to MonoGame changing a few lines but I’ve got a problem. It doesn’t create the GraphicsDevice.

It’s a FatalExecutionEngineError that occurs at this line in the “GraphicsDeviceService”:
‘graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);’.

How can I fix this? Is there a better method to create tools for MonoGame?

On Nuget, you can search Microsoft.Xna.Framework.Control or MonoGame.Framework.Control(for.net 4.5) and use one of those dlls. It already has the stuff on that working, in which you will only need to inherit GraphicsDeviceControl to your class object you are wanting to make a control out of… Alternatively, Ive uploaded the same source to my Github(I was the nuget poster) you can look at it here:

https://github.com/ArchaicOokami/MonoGame.Framework.Control

Is this really working? I checked the source and get the same results.

var beginDrawError = BeginDraw();

This line always return something non null, wich means that my _graphicsDeviceService is null. Then it’s always drawing with PaintUsingSystemDrawing method. Do you have any sample of a solution working with it?

This is the same problem since monogame 3.3.

You can use my DLLs and the GLControl which is working here.

Also check this out.

Omg DUDE you are awesome. It’s so well working. I want to cry. :’( (searched a solution during 2 full days)
It’s perfect, it’s drawing all the 3D, it’s even well redrawing when I resize the window. Awesome. Thanks a lot, you are the man! :smiley:

Sorry, wasnt aware you were trying to use OpenGL.

No problem, thanks for your answer too. I just get a small problem with Monogame embedded with autoscroll. It’s well working, the only problem is that while scrolling, there is a small frame where the Monogame control is not drawn. See here :

Uhm… well not sure about that, id think it should refresh itself once you let go of the scrollbar… there are plenty of winforms based things that glitch up when using scrollbars or resizing forms as the Application.Idle doesnt process while holding them usually… I typically try to do a scrollbar recalc on letting go of the scrollbar rather than allowing change DIRECTLY ON value.change

Thanks for your answer! I tried to hide the flash effect as much as possible without success. So I gave up and I overrided a winforms PictureBox paint method, works perfectly like that. I don’t think that I’ll need scroll bars for pure 3D drawings so it’s all ok. :slightly_smiling: