2

I have a form in a Pocket PC app that is set to be the Application form using:

Application.Run(New frmMain())

Somehow this form is getting closed for no reason while working on another form. No closing event is fired and nowhere in my code can you close the main form anyway. It is only closed by clicking the OK button at the top right of the window. When this is clicked, the user is prompted if he/she really wants to close the application. However, this is not occurring either.

Basically, I am on another form which adds a new record to the database. After adding the record the gotFocus event is somehow called for frmMain. When the code in the gotFocus event reaches a reference to a control on the form, there is an exception that states that the object is disposed.

When I bypass the code in the gotFocus event, the application just closes completely. I verify this by checking that it is not running in the device's memory.

I have been stepping through code for 2 hours and I have absolutely no idea why this could be occurring. Anyone possibly have a tip?

Darren
  • 793
  • 5
  • 17
  • 30

1 Answers1

2

This sounds as an exception being raised anywhere. Maybe an exception on another thread? Look at the output window to see what it says.

Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
  • Ah, thank you very much. Indeed there some exceptions in the Output window. However, when I am stepping through code the Output window is not available to me. Is there a way that I can step through the code and see exactly when those exceptions are being thrown? – Darren Feb 24 '12 at 20:55
  • Sure, go to Debug menu -> Exceptions and click the checkbox Common Runtime Exceptions. VS will stop on all the exceptions when they're generated (even if there is a try/catch) – Ignacio Soler Garcia Feb 24 '12 at 21:05
  • Lol, no problem man, this is what this site is about :) Lots of ppl did the same thing for me before – Ignacio Soler Garcia Feb 24 '12 at 21:36