Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all..

I am developing a desktop application using C# and I am novice of this development. I have a Solution in VS2010 that consist of 3 projects (Startup project, and two other projects). When I open the Main form in design mode in my Startup project, a window prompts and contains a message "MS Visual Studio has encountered a problem and needs to be closed.", while in the other forms in the same Solution I can open it in design mode and the error doesn't appears. The error only appears when I open my main form in design mode.

The Just-In-Time Debugger says "An unhandled win32 exeption occurred in denenv.exe". How could this be possible that this problem occurs only in this project only. While in my other desktop application development Projects, this problem doesn't occurs.

Any suggestions or solution about this problem?

Thank you in advance..
Posted
Updated 11-Feb-14 20:58pm
v2
Comments
Sergey Alexandrovich Kryukov 11-Feb-14 22:38pm    
Not enough information, by far, but I'll give you a valuable general advice which really saves from many troubles like that.
—SA

1 solution

Just be careful with design mode, don't overuse it. I normally only define general layout, adding all other detail in code. Then, is something goes wrong, this code is not called in design mode.

There is one simple technique of avoiding such complication. If some part of your code can possibly been called in the designers mode, put it under "if" checking for System.ComponentModel.Component.DesignMode:
http://msdn.microsoft.com/en-us/library/system.componentmodel.component.designmode%28v=vs.110%29.aspx[^].

In other words, stay away of trouble by doing this:
C#
if (DesignMode) {
    // some questionable (un-tested) or any other potentially exception-throwing code
}


Sometimes, the problem is not exposed in normal application execution, but still is manifested when you open a designer with some form or user control. Add this checks to pieces of your code until the form begins showing in design time. This way, you can locate the problem. After that, you can fix the problem; you may want to leave the "if" block as is or remove it after the fix, depending on required design-time functionality. But again, keep it simple, don't overuse it, especially if you are not a provider of components which should be used by other developers under the designer.

—SA
 
Share this answer
 

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