473,771 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Form.DefW ndProc(Message& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
at System.Windows. Forms.Container Control.WndProc (Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.SetF ocus(HandleRef hWnd)
at System.Windows. Forms.Container Control.FocusAc tiveControlInte rnal()
at System.Windows. Forms.Form.set_ Active(Boolean value)
at System.Windows. Forms.Form.WmAc tivate(Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Any ideas?

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

How do you close the application? Application.Exi t() ? Closing the main
form? Something else?
"dshemesh" <ds******@discu ssions.microsof t.comwrote in message
news:8B******** *************** ***********@mic rosoft.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.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Form.DefW ndProc(Message& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
at System.Windows. Forms.Container Control.WndProc (Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&
m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.SetF ocus(HandleRef hWnd)
at System.Windows. Forms.Container Control.FocusAc tiveControlInte rnal()
at System.Windows. Forms.Form.set_ Active(Boolean value)
at System.Windows. Forms.Form.WmAc tivate(Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&
m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr 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.Environm ent.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.Exi t() ? Closing the main
form? Something else?
"dshemesh" <ds******@discu ssions.microsof t.comwrote in message
news:8B******** *************** ***********@mic rosoft.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.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Form.DefW ndProc(Message& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
at System.Windows. Forms.Container Control.WndProc (Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&
m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
System.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.SetF ocus(HandleRef hWnd)
at System.Windows. Forms.Container Control.FocusAc tiveControlInte rnal()
at System.Windows. Forms.Form.set_ Active(Boolean value)
at System.Windows. Forms.Form.WmAc tivate(Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&
m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr 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, ThreadAbortExce ption 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 (ThreadAbortExc eption)
{
}

May 28 '07 #4
On May 28, 10:22 am, dshemesh <dshem...@discu ssions.microsof t.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.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Form.DefW ndProc(Message& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
at System.Windows. Forms.Container Control.WndProc (Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

System.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.SetF ocus(HandleRef hWnd)
at System.Windows. Forms.Container Control.FocusAc tiveControlInte rnal()
at System.Windows. Forms.Form.set_ Active(Boolean value)
at System.Windows. Forms.Form.WmAc tivate(Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr 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******@discu ssions.microsof t.comwrote in message
news:75******** *************** ***********@mic rosoft.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environm ent.Exit(-1).
See also:

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

May 28 '07 #6

"dshemesh" <ds******@discu ssions.microsof t.comwrote in message
news:75******** *************** ***********@mic rosoft.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environm ent.Exit(-1).
System.Environm ent.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exi t() 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.Exi t(). Will this stop all the running threads for me?

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

System.Environm ent.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exi t() 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...@discu ssions.microsof t.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.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Form.DefW ndProc(Message& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
at System.Windows. Forms.Container Control.WndProc (Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

System.Threadin g.ThreadAbortEx ception: Thread was being aborted.
at System.Windows. Forms.UnsafeNat iveMethods.SetF ocus(HandleRef hWnd)
at System.Windows. Forms.Container Control.FocusAc tiveControlInte rnal()
at System.Windows. Forms.Form.set_ Active(Boolean value)
at System.Windows. Forms.Form.WmAc tivate(Message& m)
at System.Windows. Forms.Form.WndP roc(Message& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr 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.Exi t() and encountered the following problems:
1. After calling Application.Exi t() the code continues to run. It does not
really terminate the application (I am calling Application.Exi t() 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******@discu ssions.microsof t.comwrote in message
news:75******** *************** ***********@mic rosoft.com...
You are correct.
I have no idea what these methods do.
I close the application using System.Environm ent.Exit(-1).

System.Environm ent.Exit(code) expects you to stop all the other threads
first. In a windowed application. Application.Exi t() is preferred. Is
there a good reason a windowed app needs to return an exit code?
May 29 '07 #10

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

Similar topics

3
2872
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 plus minus would still be ok, whyever. I've tested this successfully on 6.0.2800.1106 on a german W2KPro machine, also with 6.0.2800.1106 on a german XPPro machine.
3
1412
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 the boolean output 0s or 1s? #include <stdio.h> /*This program is made to check that leaving the brackets around the epxression (c=getchar()) in the statement while ((c=getchar()) !=EOF) produces a boolean output in
112
4068
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 .Name="Whatever" & trim(cstr(i)) .Text=.Name .Visible=True ... etc etc etc ...
1
1451
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 = XDate.DateTimeToXLDate(point.time); double pointValue = Convert.ToDouble(point.value); list.Add(pointTime, pointValue);
8
3286
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 socket.setdefaulttimeout(5.0) so that the sockets don't wait too long if there's no SSL server, I get
5
1720
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 kind of use)? template <typename E> class Mytest { public: Mytest(int n) { s = E(0);
1
1468
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 11 If Request.Cookies("UserSettings")("IsAdmin") = "True" Then Me.panAdmin.Visible = True Else Me.panAdmin.Visible = False
4
2515
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...) Any reason why even though I did this I keep getting this error.... Server Error in '/abc' Application.
4
4883
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 between 'minimum' and 'maximum'.\r\nParameter name: Value" Source="System.Windows.Forms" ParamName="Value" StackTrace: at System.Windows.Forms.ScrollBar.set_Value(Int32 value) at System.Windows.Forms.DataGridView.ScrollRows(Int32...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10102
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.