Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors with Microsoft "WinForms Series 1: Graphics Device"

Tags:

c#

winforms

xna

I have a problem with this sample. I just downloaded it and run it (Visual Studio 2010). I haven't touched anything.enter image description here

Sorry for the Language, it is in italian. From top to bottom it says:

  • To avoid the lost of information before load the designer Window, it is necessary to solve these errors:
  • Can't visualize the designer Windows for the file, because no class can be designed. The designer utility has examinated these classes: SpinningTriangleControl --- Can't load its base class "WinFormsGraphicsDevice.GraphicsDeviceControl". Verify that there is a reference to the assembly and that all projects are generated.
  • Below it says the same

Note that:

  • If I compile and run, it works.
  • In the toolbar of the ide, sometimes (I didn't understood when), there are the two controls created with the sample, SpinningTriangleControl and SpriteFont; sometimes they disappear. When this happens, the controls are also removed from the MainWindow form of the project!
  • I don't know if it is important, but I noticed that the control disappears often and removes itself from the xxx.designer.cs while I add some new control, such as toolstripmenu, etc, or I add some new Event Handler for some control.

I really don't understand what's happening.

Edit By JT: The repro is here: sdrv.ms/1kIhI5o

Repro steps:

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

Result:
The gameWrapper control cannot be selected anymore, it doesn't even show up in the Property Windows dropdownlist of form controls!

like image 904
Francesco Bonizzi Avatar asked Dec 09 '13 21:12

Francesco Bonizzi


1 Answers

I have seen this occur in a few scenarios.

1) Project gets a reference to itself.

If you have a usercontrol in project A, and use the design to add the usercontrol to a form also in project A, Visual Studio will add a self reference which will screw up the designer.

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

Since abstract classes can't be instantiated, the designer will not be able to create an instance to render in the designer.

3) DesignMode bug

If you are using the DesignMode property to determine whether or not UserControls should load data in an event like Load(), you need to know that DesignMode will break if you nest controls more than one level deep. You can get around this by creating your own designmode variable by keying off of LicenseManager.UsageMode.

like image 63
Scope Creep Avatar answered Oct 01 '22 15:10

Scope Creep