views:

38

answers:

1

I have a strange issue that has arisen recently:

Whenever I enter text, even a single character, into a textbox in any Form in my application it causes the form and its parent to close. I've checked for the following so far:

  • Errant/mis-assigned event handlers that may be interpreting a keystroke as a Form cancel
  • I am using keypreview in several windows but debugging shows this to not be a cause
  • Happens in any form of the application
  • Happens even with brand new text boxes dropped on the form
  • Tried removing the WithEvents declaration from text box declarations (VB.NET)
  • The result is DialogResult.Cancel when I break the code after Show or ShowDialog
  • The forms do not use AcceptButton or CancelButton properties (set to none)
  • Note: I am modifying a large codebase with a lot of code that I have yet to touch

What else could be causing this strange behavior?

+1  A: 
  • Press Ctrl+D, E (Debug, Exceptions) and tell Visual Studio to break whenever any exception is thrown, then see if there are any exceptions at work.

  • Press Ctrl+D, N (Debug, New Breakpoint, Break at Function) and set a breakpoint on System.Windows.Form.OnClosing, then look at the call stack. (Alternatively, override OnClosing in the main form, then set a breakpoint in it)

SLaks
Yup. i actually had the same thought right after i posted this question. Breaking in the Form Closing handler allowed me to see enough of the call stack to identify a timer that was checking the state of the application cursor and using a goto to error out, be silently closing the app, when the cursor was null. i wonder how far this Rube Goldberg invention is spread. Still not sure how in the heck a text change could be affecting the message queue that much...
Paul Sasik