Why does visual studio break sometimes and how do I fix it?

Kaden Houser 1 Reputation point

I was making a windows forms app on visual studio, then when I open the designer, it says I have an error. I click on the error to try to fix it, then suddenly visual studio gives me 9 event handler errors. How would I go about fixing this?


An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,629 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 51,341 Reputation points

    Stop double clicking in the designer :}

    That is the problem you have. Every time you double click in the designer window the designer wants to hook up the default event for whatever you double clicked to a method. The normal event is Click and hence you get a click event handler. You are then most likely deleting that method within your actual code (where it puts it) and then this breaks the designer.

    To fix the existing issues do the following:

    1) Open the codebehind (via the designer window's error screen) and then delete the entire line this.label1.Click += .... Do this for all errors.
    2) Close the codebehind window.
    3) Delete the auto-generated method if you haven't already.
    4) Open the designer and things should be back to normal.
    5) Don't double click inside the designer unless it is on a button or other thing you want to handle the clicking of.

    1 person found this answer helpful.
    0 comments No comments