NativeWindow.Callback() exception making life difficult


J

Jolyroger

For months I've been plagued by a mysterious bug. The bug is very rare and
seems to only appear when running the application outside of the debugger.
In addition, the bug will only appear for a typical user a few times per
month, so its rarity makes it even harder to track down.

The app is coded in Visual Studio 2005.

When the bug strikes, a standard "Unhandled exception has occurred in your
application" dialog appears with this trace:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(...)

Does anyone know what could cause an exception with a stack trace like this?
The stack trace implies that a Timer is involved, but I've double-checked
all the Timers and I can't see how this would be the case.

I'd love it if I could understand what could cause this bug, but if that's
not possible, as a consolation prize I'd at least like to suppress the
unhandled exception dialog from appearing. I'm already handling these
events...

Application.ThreadException += new
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(WorkerThreadHandler);

....but this unhandled exception message is still getting through.

Please help me. What should I do?
 
Ad

Advertisements

J

Jolyroger

By decompiling the .Net DLLs I can see that DefWndProc() has the following
definition:

public void DefWndProc(ref Message m)
{
if (this.previousWindow == null)
{
if (this.defWindowProc == IntPtr.Zero)
{
m.Result = UnsafeNativeMethods.DefWindowProc(m.HWnd, m.Msg,
m.WParam, m.LParam);
}
else
{
m.Result =
UnsafeNativeMethods.CallWindowProc(this.defWindowProc, m.HWnd, m.Msg,
m.WParam, m.LParam);
}
}
else
{
m.Result = this.previousWindow.Callback(m.HWnd, m.Msg, m.WParam,
m.LParam);
}
}

Can someone shed some light on what my app might be doing to cause a
ThreadAbortException to be thrown in this method?
 
Ad

Advertisements


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