Using VS2013 Pro, WinForms, the debugger keeps deleting my event handlers. (I place them inside the Form.Designer.cs file)
I've only started noticing it recently and I'm positive I haven't changed any settings.
Can anyone else replicate this or is it just something on my system?
Steps to replicate:
If you added your event handler manually then anytime you change something from the Designer the Form.Designer.cs is regenerated and will delete your event handlers (the ones added manually in the code)
What you need to do is to add the event handler from the Control properties.
For example if you code this in the Designer:
myControl.Click += myClickHandler;
it will be deleted anytime you change something in the designer, because the whole .Designer.cs file is regenerated and for some reason the VS is not aware of the event handlers added manually.
You;ll see that if you add the event handler from the Control properties window (in the designer) the generated code will look like this:
myControl.Click += new EventHandler(myClickHandler);
Another workaround is to add the handler outside the .Designer.cs class, but the easy way is to add the handler from Designer :).