I have a database class instantiated with a Using statement, then a
reader also instantiated with a using statement.
If the command I use to populate the reader throws an exception, then
that exception gets "swallowed" and never populates back up the callstack.
I added a threadexception handler and this catches the exception at the
top level except before my main form fully loads which does the data
loading in the load event.
Flow of events
MAIN >> Add threadexception handler that shows messagebox with exception
message >> run new form1 >> form1 load >> load data >> exception thrown
no messagebox.
After form is loaded and displayed
Combo box selectionchanged >> loads data same as form1 load >> exception
thrown and caught and messagebox displayed.
Any Ideas?
The actual code that invokes the command that throws the exception is
using(DB db = DatabaseManager.CreateDatabase())
{
... setup command
using(IDataReader Reader = db.GetReader(Command)) //db.GetReader throws
exception because of a syntax error
{
}
}
Cheers
JB