views:

107

answers:

3

When I try to start a new C# project in VS2008 I immediately get the error: "The designer could not be shown for this file because none of the classes within it can be designed", that is I get this before I even written one line of code.

Google doesn't have any helpful solutions to this rather widespread problem but I tried reinstall my VS2008 but that didn't help. Any suggestions?

+2  A: 

From MSDN:

This error occurs when Visual Studio cannot find a base class that satisfies designer requirements. Examples include: Visual Studio cannot find a designer for the base class; the base class is a class that could not be found or loaded.

To correct this error

  • Forms and controls must derive from a base class that supports designers. If you are deriving from something, such as an inherited form or control, within the project you are working in, you need to make sure the project is built by selecting Build Solution from the Build menu.
Andrew Hare
+1  A: 

Backup and then rename the "Visual Studio 2008" directory in your "My Documents". Then run devenv.exe /safemode

Matthew Whited
Whoa - dont' do this!! This has the potential to blow away all your projects - back up your projects before you do this.
Andrew Hare
He also said it's a fresh install... I guess assumed you either store your stuff ina different folder or make a backup... I will edit it.
Matthew Whited
A: 

Depending on the type of project you are creating it may be that Visual Studio is incorrectly trying to open normal .cs files with the forms designer. If this is the case find a .cs file in your solution and right click on it. Then select Open with... choose the CSharp Editor and select "Set as Default".

On the other hand if you are trying to start a Winforms project then the first file selected by default is Form1.cs and that should open in the editor correctly. In that case it would appear as though there is something wrong with the project template and the form isn't inheriting correctly - though I would have expected a reinstall to fix this.

Martin Harris