Form.ActiveForm.Handle exceptoin

  • Thread starter Thread starter Dennis C. Drumm
  • Start date Start date
D

Dennis C. Drumm

Why is it that when I am debugging an application that has a call to
Form.ActiveForm, if I set a breakpoint before the call then when I reach
that statement a NullReferenceException is thrown, but if the breakpoint was
set following the call to Form.ActiveForm, then I can continue the debug
session without a problem?

Thanks,

Dennis
 
Dennis,

Probably because it tries to get a form from the active window handle.
If the current window is the debug window, then it doesn't have a managed
window to map to =)

Hope this helps.
 
Nicholas:

I thought it might be something like that, I just wasn't sure whether or not
the vs.net environment could compensate for that in debug mode.

Thnaks,

Dennis


Nicholas Paldino said:
Dennis,

Probably because it tries to get a form from the active window handle.
If the current window is the debug window, then it doesn't have a managed
window to map to =)

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Dennis C. Drumm said:
Why is it that when I am debugging an application that has a call to
Form.ActiveForm, if I set a breakpoint before the call then when I reach
that statement a NullReferenceException is thrown, but if the breakpoint
was set following the call to Form.ActiveForm, then I can continue the
debug session without a problem?

Thanks,

Dennis
 
Back
Top