When I'm debugging code and a runtime error occurs, Visual Studio
usually gives me a specific error message and identifies the line
which caused the error.
Sometimes, however, it does not do those things. Instead, it gives me
the generic error message "Exception has been thrown by the target of
an invocation" and identifies a line higher up in the call stack. When
this happens, it can be difficult to diagnose the cause of the runtime
error.
1. Why do I sometimes get the generic message? What rules determine
Visual Studio's behavior in this regard?
I've found that code in New() tends to raise the generic message. If I
move the code to the Load event procedure, it tends to raise the
specific message. Because of this, I'm considering avoiding New(), and
using the Load event procedure instead.
2. Have other programmers found it necessary to avoid New(), or make
other structural decisions, to facilitate effective debugging?
-TC