Not catching exceptions thrown in dll class

M

Michael Rodriguez

I have a data layer in a dll class. If I manually throw an exception in
that data layer, the generic Application.OnThreadException in my UI does not
catch it nor does it display any message whatsoever. The user is totally
unaware of the error.

How can I catch these errors without having to manually try...catch each
one?

Thanks,

Mike Rodriguez
 
B

Bruce Wood

Do you handle AppDomain.UnhandledException, too? I've never figured out
the "why" of the two of them, but some exceptions seem to be caught by
OnThreadException, while others are caught by UnhandledException.
 
G

Guest

Is this .NET 1.1 or .NET 2.0?
Bruce's indication is true; in .NET 1.1 not all unhandled exceptions on
other than the main thread blow up the app, the CLR will swallow them alive
(uggh).
Peter
 
M

Michael Rodriguez

Hi Peter,

I'm using .NET 2.0. I added an UnhandledException event handler, but that
still didn't catch it. It gets even weirder; check this out this event from
my business layer DLL:

public virtual void FillDetailTables(int index)
{


MessageBox.Show("Got to here");

// if thrown, this exception will be caught by the UI
// throw new Exception("Error!");

if ((numDetailTables > 0) &&
(!((BusinessBase)List[index]).DetailTablesFilled))
{
((BusinessBase)List[index]).DetailTablesFilled = true;

MessageBox.Show("Got to here also");

// if thrown, this exception will NOT be caught by the UI!!
// throw new Exception("Error!");
}

}


WTF??!!!

Mike Rodriguez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top