In several places in our code, we notice that if running under debugger it'll show that there's an unhandled exception in the code, however if running outside the debugger it will just ignore the exception completely as if it were caught. We have an exception handler that pops up an error submit dialog that's hooked up to Application.ThreadException and AppDomain.CurrentDomain.UnhandledException And neither of those appear to be catching them either. We also log our exceptions and nothing appears in the log.
What are some possible reasons for this?
Edit: It seems that it isn't dependent on the type of exception throw, but rather where it is thrown. This was tested by just adding:
throw new Exception("Test Exception");
It'll show up under debugger but doesn't show up outside, so in our case it's not a ThreadAbortedException or anything that's dependent on it being a specific type of exception.
There are some special exceptions that don't get bubbled up or caught, it sounds like you're dealing with one of them: see ThreadAbortException
Found one place where this could occur is if there's an exception in the UnhandledException event handler. An easy way to see this is this: In the Form.Load event handler throw any old exception. In the Application.ThreadException event put something similar to the following:
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
string b = null;
int i = b.Length;
}
Under debugger it'll show your exception was unhandled by user code, and then after that it'll show a null reference exception in the ThreadException handler, but if you run it outside the debugger it'll just swallow the exception like it was handled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With