.NET Design View Not Running Windows Forms OnLoad

I have a windows application which works when the application is running, however in design view, the code in the OnLoad event crashes due to a host of reasons. Is there a way to do something like this:

private void WindowsForm_OnLoad(object sender, EventArgs e)
        if (IsDesignView())
               // some code that breaks in design view but works normally


There is the DesignMode property inheritied from Component.

if(!this.DesignMode) {
    // Your stuff...

Though there is a better way to do it than that, since if I recall correctly, sometimes there can be issues with the DesignMode property. I think I have some code somewhere, let me find it.

EDIT: Well, I can't find what I was thinking of, but this answer discusses some of the downsides of DesignMode you should keep in mind, as well as a workaround for a specific issue. However, the issue doesn't affect what you want to do here, it doesn't look like, but it's good to be aware of it anyway.

Need Your Help

django versions reversion how to act?

python django virtualenv django-cms

I'm try to open up django-cms a project I didn't work for a while when I

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.