0

I have a project with multiple forms. After some changes to the project dataset, Load event on one form stopped working (although form shows correctly). There were no changes to the form itself. As a quick workaround I've created Shown handler (through VS IDE) and put my code there, but it's not firing either (I've created test message boxes to be sure it isn't a problem with debugger).

On the other hand many events do work, e.g. I've tried Activated and it works but it's not useful for me.

There is appropriate line in .Designer.cs:

 this.Load += new System.EventHandler(this.FormZlecenie_Load);

I've compared three files connected with this form (.cs, .resx, .Designer.cs) with backup that I've made before changes to the dataset and there are virtually no differences (and backup works without problems).

I don't want to revert to backup because I need these changes in dataset and there are many.

I've also deleted all binary folders (bin, obj) but without success.

I've looked for similar problems on the net but the only solution I've found was to re-create the form. This is the last resort for me because it will be rather time-consuming and I don't like to give up so easily.

So where else should I look? I'm out of ideas.

leppie
  • 115,091
  • 17
  • 196
  • 297
killgore
  • 1
  • 1
  • 2
  • Do you use a 64-bit version of Windows? Do you see a "first chance exception" in the Output window? – Hans Passant Feb 15 '12 at 13:25
  • Yes it's 64-bit Windows 7. My project is under Net 2.0 and I see "first chance exception" is Net 4.0 thing. But I've recompiled under Net 4.0 and I don't have this message in output window. – killgore Feb 16 '12 at 09:07
  • 1
    possible duplicate of [VS2010 does not show unhandled exception message in a 64-bit WinForms Application](http://stackoverflow.com/questions/4933958/vs2010-does-not-show-unhandled-exception-message-in-a-64-bit-winforms-applicatio) – Hans Passant Feb 16 '12 at 10:27
  • Great! Although ticking the Thrown box for CLR exceptions doesn't work for me, I've run app without debugger and indeed there was an exception connected with datasource. Strange error. I'd like to mark your comment as an answer, but as I see it isn't possible with comments. – killgore Feb 16 '12 at 12:25

3 Answers3

1

Look at the bindings in your code. Sometimes events are omit when bindings are wrong (i.e. binding to Thread.IsAlive - my case).

jerry
  • 11
  • 2
1

I would go into the form designer and ensure that the event shows up in the property window. If it is there, then remove it, build your project, then re-add it again manually.

If this doesn't work, go into the constructor for the form and register the event manually using the code sample you gave in your question. Debug to see if the event fires.

Next, try using a different method for the event handler. Just the one that is auto generated when you use "this.load +=".

Finally, worst case scenario you could recreate the form and copy over the elements from the current form over. Sometimes the designer screws up the form and can't fix itself.

Hope this helps!

ImGreg
  • 2,946
  • 16
  • 43
  • 65
0

Check for the call of InitializeComponent(); in the constructor of the forms class. The form partially still works without the call. Even some form specific events get called. But the controls on the form won’t be created and events like the this.Load don’t work anymore.

sbecker
  • 553
  • 4
  • 12