Errors with Microsoft "WinForms Series 1: Graphics Device"

I have a problem with this example . I just downloaded it and launched (Visual Studio 2010). I didn’t touch anything . enter image description here

Sorry for the language, it is in Italian. From top to bottom it says:

  • To avoid loss of information before loading the designer window, you must resolve these errors:
  • It is not possible to visualize the Windows constructor for a file because no class can be designed. The development utility has learned these classes: SpinningTriangleControl --- Unable to load its base class "WinFormsGraphicsDevice.GraphicsDeviceControl". Make sure that there is a link to the assembly and that all projects are generated.
  • Below he says the same thing.

Note that:

  • If I compile and run, it works.
  • In the ide toolbar sometimes (I did not understand when), there are two controls created with the sample: SpinningTriangleControl and SpriteFont; sometimes they disappear. When this happens, the controls are also removed from the project’s MainWindow form!
  • I don’t know if this is important, but I noticed that the control often disappears and is removed from xxx.designer.cs , while I add a new control, for example toolstripmenu, etc., or I will add some new event handler for some control element.

I really don't understand what is going on.

Edit By JT: Reproduction here: sdrv.ms/1kIhI5o

Repro steps:

Open solution
Select the control flowLayoutPanel1
Run the application
Stop application
Now try choosing gameWrapper!

Result:
The gameWrapper control can no longer be selected, it does not even appear in the drop-down list of Windows properties of form controls!

+8
c # winforms xna
source share
7 answers

I have seen this in several scenarios.

1) The project receives a link to itself.

If you have usercontrol in project A and use the construct to add usercontrol to the form also in project A, Visual Studio will add self-realization, which will ruin the constructor.

2) Creating an abstract base class for a visual element.

Since abstract classes cannot be created, the designer cannot create an instance for rendering in the designer.

3) DesignMode Error

If you use the DesignMode property to determine whether UserControls should load data into an event such as Load (), you need to know that the DesignMode will break if you control the socket more than one level. You can get around this by creating your own designmode variable by disabling LicenseManager.UsageMode.

+1
source share

It happens to me also from time to time. The only thing that works is removing the user control from the window and then adding it again.

+1
source share

I added repeat steps to your question and experienced half the problem.

Repro steps:
1. Open decision
2. Control selected flowLayoutPanel1
3. Launch the application
4. Stopped the application

Then I could not select the gameWrapper control! The gameWrapper control did not even appear in the drop-down list of form control window properties!

I tried to add controls, as you mentioned, to cause a problem, I even added a custom SpinningTriangleControl.cs element , which appears in the screenshot as a problem (but it was not included in reproducing the solution that was loaded).

To play the custom SpinningTriangleControl.cs control that cannot be opened according to your screenshot, you just leave the link using OhmGame_Level_editor; Namespace :

enter image description here

enter image description here

Addition using OhmGame_Level_editor; allowed me to open the SpinningTriangleControl.cs user control without a constructor error.

It should be an XNA / Visual Studio error - as in the management, except for selecting gameWrapper, and then after starting / stopping the application, the management of gameWrapper is visible, but cannot be selected!

Workaround:
I found that when I opened the solution and blocked the gameWrapper control, I could select it regardless of whether it was selected or not selected when starting / stopping the application.

enter image description here

+1
source share

Typically, this problem occurs when creating a custom control. To do this, create a WinFormsGraphicsDevice and paste the created exe into the next path to the version of Visual Studio you are using.

C: \ Program Files \ Microsoft Visual Studio \ Common7 \ IDE

restart your visual studio and see if this problem is resolved. I ran into a problem with my user controls and fixed it like this. Hope this works for you too.

0
source share

This is apparently caused by an incorrect link. Try the following: Close all files. Clear the solution and rebuild. Then find the project or dll where the GraphicsDeviceControl class is defined. Remove the link. Re-add the link, rebuild. Try opening the control again.

0
source share

You should try to throw some attempts / catches and use breakpoints and find an exception. I also think that your problem is related to something with the GUI component, for example, SpriteFont, ContentManager, GraphicsDevice ... For example:

 content = new ContentManager(Services, "Content"); spriteBatch = new SpriteBatch(GraphicsDevice); font = content.Load<SpriteFont>("fontName"); // make sure font was loaded fine. 
0
source share

I had a problem in the designer with a form that inherits from other forms. The designer simply does not want to display them. In my case, the designer was lost because there was no constructor without arguments. The code compiled and executed well, because I used a constructor with 1 argument. To remove the code a bit, I tried to remove the constructor with no arguments, but I had to return it to make the designer work. You can try to set the constructor without an argument in both the inherited and the base control.

0
source share

All Articles