473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

wierd exception

Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so I
can't reproduce where exactly it happens. I can generally say it happens when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh
May 28 '07 #1
10 2800
I take it you are not, yourself, doing anything with unsafe mode or anything
unusual?

How do you close the application? Application.Exit() ? Closing the main
form? Something else?
"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:8B**********************************@microsof t.com...
Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so
I
can't reproduce where exactly it happens. I can generally say it happens
when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh

May 28 '07 #2
You are correct.
I have no idea what these methods do.
I close the application using System.Environment.Exit(-1).
--
dshemesh
"Michael A. Covington" wrote:
I take it you are not, yourself, doing anything with unsafe mode or anything
unusual?

How do you close the application? Application.Exit() ? Closing the main
form? Something else?
"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:8B**********************************@microsof t.com...
Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so
I
can't reproduce where exactly it happens. I can generally say it happens
when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh


May 28 '07 #3
Try this:
http://www.ondotnet.com/pub/a/dotnet...readabort.html

HTH :)

Basically, ThreadAbortException is thrown when thread is being aborted
to alert user to perform maintenance cleansing. It's benign exception
and you can do this for quick fix:

try
{
.................your code................
}
catch (ThreadAbortException)
{
}

May 28 '07 #4
On May 28, 10:22 am, dshemesh <dshem...@discussions.microsoft.com>
wrote:
Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so I
can't reproduce where exactly it happens. I can generally say it happens when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh
Are you spawning threads in your app?
Sometimes it happens when you close an application and some threads
are still running.

May 28 '07 #5

"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:75**********************************@microsof t.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environment.Exit(-1).
See also:

http://geekswithblogs.net/mtreadwell...6/06/6123.aspx

May 28 '07 #6

"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:75**********************************@microsof t.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environment.Exit(-1).
System.Environment.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exit() is preferred. Is
there a good reason a windowed app needs to return an exit code?
May 28 '07 #7
I don't really have to return an exit code, so there is no problem for me to
use Application.Exit(). Will this stop all the running threads for me?

--
dshemesh
"Michael A. Covington" wrote:
>
"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:75**********************************@microsof t.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environment.Exit(-1).

System.Environment.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exit() is preferred. Is
there a good reason a windowed app needs to return an exit code?
May 29 '07 #8
I do not know of any threads usage in my code. Maybe since I have a few forms
in the application some threads are opened and closed automatically (and then
one or more is not closed properly?)?
--
dshemesh
"Jorge" wrote:
On May 28, 10:22 am, dshemesh <dshem...@discussions.microsoft.com>
wrote:
Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so I
can't reproduce where exactly it happens. I can generally say it happens when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh

Are you spawning threads in your app?
Sometimes it happens when you close an application and some threads
are still running.

May 29 '07 #9
Hi Michael,
I tried using Application.Exit() and encountered the following problems:
1. After calling Application.Exit() the code continues to run. It does not
really terminate the application (I am calling Application.Exit() from the
main method of my application). I see this when in debug mode.
2. I still get sometimes the exception...

thanks,
--
dshemesh
"Michael A. Covington" wrote:
>
"dshemesh" <ds******@discussions.microsoft.comwrote in message
news:75**********************************@microsof t.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environment.Exit(-1).

System.Environment.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exit() is preferred. Is
there a good reason a windowed app needs to return an exit code?
May 29 '07 #10
When checking the code more thoroughly It looks something like this:

void Main {
int retval = foo();
if (retval == FAILED) {
System.Environment.Exit(-1); }
else {
System.Windows.Forms.Application.Run(new psScheduleTasks()); }
}

void foo {
Thread a;
a = new Thread(new ThreadStart(ShowWaitScreen));
a.Start();
more code...

a.abort();
return retval;
}

The exception is thrown when foo returns FAILED.
I tried using System.Windows.Forms.Application.Exit() instead of
System.Environment.Exit(-1), but the exception is still begin thrown.
--
dshemesh
"Jorge" wrote:
On May 28, 10:22 am, dshemesh <dshem...@discussions.microsoft.com>
wrote:
Hello,
I have a C# project with windows forms.
I sometimes get unprdictable .NET exceptions. I don't always get them, so I
can't reproduce where exactly it happens. I can generally say it happens when
closing the application (maybe in the dispose method?).
Here are 2 examples:

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

System.Threading.ThreadAbortException: Thread was being aborted.
at System.Windows.Forms.UnsafeNativeMethods.SetFocus( HandleRef hWnd)
at System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

thanks,
--
dshemesh

Are you spawning threads in your app?
Sometimes it happens when you close an application and some threads
are still running.

May 29 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Markus Fischer | last post by:
Hi, I'm experiencing a wierd problem with IE 6 in Windows with two _slightly_ different Version. Give the following HTMl-Code, ideally the output of offsetTop should be "105"; a few pixel...
3
by: Sathyaish | last post by:
A practice excercise from K&R. Kindly read the comments within the program. I'd be very grateful to people who helped. Why is it that I get the wierd face-like characters on the screen instead of...
112
by: Tom | last post by:
This is very strange: I have a Windows Form with a Panel on it. In that panel I dynamically (at run time) create some labels, as so: for i=1 to x dim ctlNew as New Label() with ctlNew...
1
by: Sačo Zagoranski | last post by:
Hi... This is driving me crazy and I really hope I can get an answer... Take a look at the piece of code below (I'm using .net 2.0): try { double pointTime =...
8
by: John Nagle | last post by:
Here's a wierd problem: I have a little test case for M2Crypto, which just opens up SSL connections to web servers and reads their certificates. This works fine. But if I execute ...
5
by: desktop | last post by:
I am confused about the use of the template parameter "E" in the below class. Since when is it allowed to use these parameters like "E(1)" and what does it mean (where can I read more about this...
1
by: Bobby Edward | last post by:
Here's my code... Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then ' THIS IS LINE...
4
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) ...
4
by: alex21 | last post by:
Ok im getting this exception from a DataGridView control in my program. System.ArgumentOutOfRangeException was unhandled Message="Value of '132' is not valid for 'Value'. 'Value' should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.