Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My project has many forms, but only one cann't open its designer now. I have try many times, but I still don't know why.


error: Micorsoft visual studio 2010 has stopped
Posted

This isn't a question we can answer - there are far, far too many ways you could have caused this type of problem.
The most likely is that you have added a control or code to the designer.cs file which means that the InitializeComponent method never returns: an infinite loop, or some other weirdness! :laugh:

But we can't help you there.
So start by thinking about what changed you have made since the last time it did work and try reversing them. If you have a Source control system, find out what exactly changes you have made, if not then your most recent backup may help.

You may have to manually edit the designer.cs file until it will load - so backup first in case you completely wreck things!
I've had this before, and it can be a PITA to track down - but there is no one solution, and nobody but you can do anything about it.
Sorry, but you will have to sort it yourself.
 
Share this answer
 
Comments
Raul Iloc 16-Jun-15 2:34am    
I agree with you, so you have my 5+!
The reasons for the crash can be several. But one of the most common reason is the code written in either ctor or Load method.

The easiest way to skip the designer from running your code is by using DesignMode property.

E.g.
C#
class MyForm : Form
{
 public MyForm()
 {
   InitializeComponents();

   if(DesignMode) return;

   // ... Rest of the code
 }

 protected override void OnLoad(EventArgs e)
 {
   base.OnLoad(e);

   if(DesignMode) return;

   // ... Rest of the code
 }
}


Also, if you want to know the exact line of code that is causing the error, then you can attach your VS (during design time) to a debugger (another instance of VS) and debug the designer. See this link for more information.
 
Share this answer
 
v2
Comments
Member 11768554 16-Jun-15 5:24am    
if(DesignMode) return;
What is DesignMode? How can I do this, in my project?
vinayvraman 16-Jun-15 5:56am    
DesignMode indicates if the Control (or component) is currently in DesignMode. When in design mode, the designer executes some of the code (in ctor and OnLoad functions). You do not have to do anything extra. In the constructor, just a add a check like shown above.

But I strong suggest you to check the cause of the error and put the DesignMode check in relevant place.

See this link: https://msdn.microsoft.com/en-us/library/system.componentmodel.component.designmode(v=vs.110).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900