views:

147

answers:

5

Hi All,

I have a form, MainForm, which was working just fine and dandy until earlier this morning. I made some code modifications to a different form and when I went to run the application, I received an error in MainForm (error is irrelevant).

I went into MainForm to see what the problem was and was horrified at what I saw... ALL MY CONTROLS WERE GONE. At first I panicked, but then had a bit of hope when I went into the MainForm.Designer.cs file and saw that all the code for the controls was still there.

So, the Designer file seems fine and yet the design view does not display any of the controls.

Has this ever happened to anyone before? Is my file corrupt? Is there anything I can do to fix this?

I do have a backup, but would prefer not to use it unless absolutely necessary as it is a day old and I do not want to redo my most recent work.

Thanks...

A: 

You will want to take a look at what you did. Make sure file names match across the board, and that you didn't manage to accidentally re-name any of the individual files.

Also make sure that class names match across the board, between the 3 files.

Mitchel Sellers
+1  A: 

Take a look at this page, listing some reasons why this might have happened, ways to prevent it, and how to recover.

Donut
A: 

Restarting Visual Studio has worked in a lot of cases for me in the past. Make sure you close all copies and check the list of running processes in Task Manager to make sure there aren't any copies running you don't know about. Restarting won't help in every case (if you really have a corrupted file) but it works a lot of the time for me.

TLiebe
A: 

Try these steps:

  • Close all source code windows.
  • Do a Clean All.
  • Exit DevStudio.
  • Start DevStudio.
  • Open your solution (if it doesn't auto-load)
  • Build your solution.
  • Open your panel in the designer.
JeffH
A: 

The last time I saw that, I did not have my my partial class Form as the first thing in the codebehind.

namespace WinForms{ public partial class MyForm : Form{ } }

was like

namespace WinForms{ public class SomeClass{ //some code.. }

public partial class MyForm : Form { }

}

krishna