MonoGame.Forms - Create your Editor Environment!

This is a great project @SandboxBlizz thanks for continuing to support this! I’m working on a Level Editor for our game and it was extremely simple to plug in and get things up and running!

However, I’m having an issue I was hoping you could shed a light on. Most everything seems to be working fine, but for some reason I seem completely unable to load any Effect files. Is there a specific shader model that needs used or some special handling I missed somewhere? Whenever I attempt to load an effect file through the editor’s content manager it throws a SharpDX exception. Of course it’s the entirely useless “The parameter is incorrect” message so I’m not sure what the actual issue is, but it fails on loading instead of setting anything which I found interesting.

This has happened when trying to load the same shaders I use (and are working fine) in my game, and I’ve also tried to make an extremely simple shader to nail down the problem, but even as something as basic as the following still throws an exception:

float4 RedPixel(float2 coords: TEXCOORD0) : COLOR0
    return float4(1, 0, 0, 1);

technique CrazySimple
    pass P0
        PixelShader = compile ps_4_0 RedPixel();

My best guess is that there’s an issue somewhere because everything I have is building against MonoGame 3.7.1, but the only reference to MonoGame.Framework in my LevelEditor project is the included DLL from Forms. Is this possibly an issue from MGCB.exe being built against 3.7.1?

Also just to mention, Effects seem to be the only thing I’m having trouble with. Fonts, Models, etc all seem to be loading and working as expected.

Of course as soon as I posted my above question I found the issue. I needed to ensure the GraphicsProfile was set to HiDef instead of Reach. Feel free to ignore me!

Ah, thanks for your message! Nice, that you already found a solution.

Sometimes it’s also possible to resolve such errors when compiling the shader with a different target or feature level like ps_4_0_level_9_1.

Have a nice day :slight_smile:

MonoGame.Forms 2.4.0 Released

  • Added DX targets file to the DX nuspec.
  • Now importing the MonoGame.Content.Builder.targets and MonoGame.Common.props file and setting the MonoGamePlatform property in all files (DX, GL).
  • Added MonoGame.Content.Builder content/libs/nuspecs/targets for DX and GL platform.
  • Added MonoGamePlatform property and importing MonoGame specific targets.
  • Correctly using the NativeLibs directory when including files.
  • Added MonoGame.Framework source code for the Windows platform to allow users to recompile it with custom modifications.
  • Updated post build events.
  • Register keystrokes immediately after setting AlwaysEnableKeyboardInput to true.
  • Always setting the KeyboardInput when the meta value changes.
  • Added additional NullReferenceException checks regarding the Editor service class.
  • It’s now possible to define custom clear options when using BeginAntialising, EndAntialising, BeginRenderTarget and EndRenderTarget (graphics.Clear(custom parameters)).
  • Changed the depth of the clear options to 1f as the default.
  • Added real disposing checks in all controls.

Thank you very much!

:: Marcel :sparkling_heart:

1 Like

Hey! I’ve followed the instructions, and tried a few times to get this to work. However I keep getting a large error thrown when trying to add the object to a windows form. Any help?

Hi, can you post the error message here or make a screenshot of it?

Which Visual Studio version are you using?

You also need to do a full rebuild of the solution the first time after you created a MonoGame.Forms control.

Oh, and welcome to the community! :slight_smile:

Visual Studio 2019 - Version 16.6.5

I did rebuild and still get this error thrown. I appreciate your help!

This error seems strange to me.

  • Please try to create a fresh WindowsForms project and choose .NetFramework 4.5.1
  • After that install MonoGame.Forms 2.4.0 from nuget using the nuget package explorer.
  • Create a new class and inherit from MonoGameControl.
  • Save and completly rebuild your solution.
  • Drag & Drop the newly created control from the toolbox to the designer.

I just did it like that with Visual Studio 2019 and it directly worked for me without any errors.

I repeated this process a few times. The component will not show up in the toolbox now :confused:

Is there a way I could ask you about this on discord? I am really excited to use your project

It’s better to discuss such problems here in the forum so that other users which might have the same problem can easily find a solution.

Is it somehow possible for you to upload your project so I can take a look? For example to GitHub.

Here’s my project:

You project works for me. I tested this with the newest version of Visual Studio 2019 (16.7.0)

Please try the following:

  1. Open the project you linked to me.
  2. Expand Form1.cs
  3. Double-Click on Form1.Designer.cs
  4. Exchange line 23-59 with the following code:
#region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
            this.drawTest1 = new EridanusA.DrawTest();
            // drawTest1
            this.drawTest1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.drawTest1.Location = new System.Drawing.Point(0, 0);
            this.drawTest1.MouseHoverUpdatesOnly = false;
            this.drawTest1.Name = "drawTest1";
            this.drawTest1.Size = new System.Drawing.Size(711, 360);
            this.drawTest1.TabIndex = 0;
            this.drawTest1.Text = "drawTest1";
            // Form1
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(711, 360);
            this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);



        private DrawTest drawTest1;
  1. Save & Rebuild the solution.
  2. Double-Click on Form1.cs
  3. Tell me what happens or what do you see after that.

Yes this works for me! I do not know why it won’t show up in the toolbox, thank you!

It seems there is something wrong with your toolbox. You can google for “reset toolbox” or “clear toolbox cache”. This might help.

You shouldn’t edit the designer.cs file itself all the time, because this could lead to project errors. I just wanted to test this out with you.

If you can’t use the toolbox in the future then you should add your MonoGame.Forms controls like this:

public Form1()

    // Do it like this
    this.Controls.Add(new DrawTest() { Dock = DockStyle.Fill });