奇怪的例外 [英] wierd exception
问题描述
您好,
我有一个带有Windows窗体的C#项目。
我有时会遇到无法解决的.NET异常。我不总是得到它们,所以我无法重现它的确切位置。我一般可以说当关闭应用程序时可能会发生这种情况(可能是在dispose方法中?)。
这里有两个例子:
System.Threading.ThreadAbortException:线程正在中止。
在System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc,IntPtr hWnd,Int32 msg, IntPtr wParam,IntPtr lParam)
在System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
在System.Windows.Forms.Form.DefWndProc(Message& ; m)
在System.Windows.Forms.Control.WndProc(消息& m)
在System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
在System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
在System.Windows.Forms.Form.WndProc(Message& m)
在System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
在System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)<在Sys,
tem.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,
IntPtr wparam,IntPtr lparam)
System.Threading.ThreadAbortException:线程正在中止。<在System.Windows.Forms.UnsafeNativeMethods.SetFocus(HandleRef hWnd)上的
在System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
在System.Windows.Forms.Form.set_Active(布尔值)
在System.Windows.Forms.Form.WmActivate(消息& m)
在System.Windows.Forms.Form.WndProc(消息& m)
在System.Windows.Forms.Control.ControlNativeWindow.O nMessage(消息& m) )
在System.Windows.Forms.Control.ControlNativeWindow.W ndProc(消息& m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32) msg,
IntPtr wparam,IntPtr lparam)
有什么想法吗?
谢谢,
-
dshemesh
我认为你不是,你自己,做任何不安全的模式或什么
不寻常?
你如何关闭申请? Application.Exit()?关闭主要的
表格?还有别的吗?
" dshemesh" < ds ****** @ discuss.microsoft.com写信息
新闻:8B ********************** ************ @ microsof t.com ...
你好,
我有一个C#使用Windows窗体的项目。
我有时会遇到无法解决的.NET异常。我不总是得到它们,所以
我
无法重现它究竟发生的地方。我一般可以说它发生了
当
关闭应用程序时(可能在dispose方法中?)。
这里有两个例子:
System.Threading.ThreadAbortException:线程正在中止。
在System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc,IntPtr hWnd,Int32 msg,IntPtr wParam,IntPtr lParam)
在System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
在System.Windows .Forms.Form.DefWndProc(消息& m)
在System.Windows.Forms.Control.WndProc(消息& m)
在System.Windows.Forms.ScrollableControl .WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc (消息& m)
在System.Windows.Forms.Control.ControlNativeWindow.O nMessage(消息&
m)
在System.Windows .Forms.Control.ControlNativeWindow.W n DPROC(消息&安培; m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,
IntPtr wparam,IntPtr lparam)
System.Threading.ThreadAbortException:线程被中止。
在System.Windows.Forms.UnsafeNativeMethods.SetFocus(HandleRef hWnd)
在System.Windows.Forms .ContainerControl.FocusActiveC ontrolInternal()
at System.Windows.Forms.Form.set_Active(布尔值)
at System.Windows.Forms.Form.WmActivate(Message& m)
在System.Windows.Forms.Form.WndProc(消息& m)
在System.Windows.Forms.Control.ControlNativeWindow.O nMessage(消息& <在System.Windows.Forms.Fornt.NativeWindow上的System.Windows.Forms.Control.ControlNativeWindow.W ndProc(消息& m)
.Callback(IntPtr hWnd,Int32 msg,
IntPtr wparam,IntPtr lparam)
有什么想法吗?
谢谢,
-
dshemesh
你是对的。
我不知道这些方法是做什么的。
关闭应用程序使用System.Environment.Exit(-1)。
-
dshemesh
" Michael A. Covington"写道:
我认为你不是,你自己,做任何不安全模式或任何事情
不寻常?
如何关闭应用程序? Application.Exit()?关闭主要的
表格?还有什么吗?
" dshemesh" < ds ****** @ discuss.microsoft.com写信息
新闻:8B ********************** ************ @ microsof t.com ...
你好,
我有一个C#使用Windows窗体的项目。
我有时会遇到无法解决的.NET异常。我不总是得到它们,所以
我
无法重现它究竟发生的地方。我一般可以说它发生了
当
关闭应用程序时(可能在dispose方法中?)。
这里有两个例子:
System.Threading.ThreadAbortException:线程正在中止。
在System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr
wndProc,IntPtr hWnd,Int32 msg,IntPtr wParam,IntPtr lParam)
在System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
在System.Windows .Forms.Form.DefWndProc(消息& m)
在System.Windows.Forms.Control.WndProc(消息& m)
在System.Windows.Forms.ScrollableControl .WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc (消息& m)
在System.Windows.Forms.Control.ControlNativeWindow.O nMessage(消息&
m)
在System.Windows .Forms.Control.ControlN ativeWindow.W ndProc(消息& m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,
IntPtr wparam,IntPtr lparam)
系统.Threading.ThreadAbortException:线程被中止。
在System.Windows.Forms.UnsafeNativeMethods.SetFocus(HandleRef hWnd)
在System.Windows.Forms.ContainerControl.FocusActiveC ontrolInternal()
在System.Windows.Forms.Form.set_Active(布尔值)
在System.Windows.Forms.Form.WmActivate(Message& m)
(消息& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
在System.Windows.Forms.Control.ControlNativeWindow.W ndProc(消息& m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr) hWnd,Int32 msg,
IntPtr wparam,IntPtr lparam)
有什么想法吗?
谢谢,
-
dshemesh
试试这个:
http://www.ondotnet.com/pub/a/dotnet...readabort。 html
HTH :)
基本上,当线程被中止时抛出ThreadAbortException
提醒用户进行维护清洁。这是一个良性的例外
你可以这样快速修复:
试试
{
.................你的代码................
}
catch(ThreadAbortException)
{
}
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解决方案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
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
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)
{
}
这篇关于奇怪的例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!