C# project forgetting assigned events?

Started by
1 comment, last by Codeka 14 years, 1 month ago
I'm using MS Visual C# 2008 EE. I have a pretty complex project set up. Once in awhile when I load it up, it's forgotten a bunch of the events I assigned to different objects on the forms. Things like the MouseMove handler on a picturebox, or the Click event on a button. It's annoying to have to reassign the things after I frustratedly realize why my program isn't working anymore. Is this at least a known phenomenon, or is there something else going on here?
Advertisement
I don't know; haven't experienced it myself.

If it's happening often enough you can wire up the events in your constructor as a workaround:

class MyForm{  public MyForm()  {    InitializeComponent();    _pictureBox.MouseMove += HandlePictureMouseMove;  }  private void HandlePictureMouseMove(object sender, MouseEventArgs e)  {  }}


This is the approach I take to avoid having to use the designer to wire up event handlers. It's easier for me to type the code.

You don't edit the *.Designer.cs files manually do you? Those are generally considered non-programmer-editable and doing so can confuse the designer pretty easily.

Other than that, I've never really had this problem myself... you might want to invest in source code control software (Subversion, git, etc) which could help somewhat with trying to figure out why things have changed.

This topic is closed to new replies.

Advertisement