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:
if (DesignMode) {
}
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