今天程序正运行着,突然弹出一个对话框,显示“无法处理的异常”,但是点击“继续”按钮仍可以正常运行。点击详细信息提示有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。************** 异常文本 **************
System.IO.IOException: 句柄无效。   在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   在 System.IO.__Error.WinIOError()
   在 System.Threading.EventWaitHandle.Set()
   在 System.Windows.Forms.Control.ThreadMethodEntry.Complete()
   在 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1891 (QFEN-1.050727-1800)
    基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
GatherWeight
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/GatherWeight.exe
----------------------------------------
System.Windows.Forms
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1891 (QFEN-1.050727-1800)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1889 (QFEN-1.050727-1800)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
SystemFramework
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/SystemFramework.DLL
----------------------------------------
WeifenLuo.WinFormsUI.Docking
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/WeifenLuo.WinFormsUI.Docking.DLL
----------------------------------------
SqlHelperTools
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/SqlHelperTools.DLL
----------------------------------------
SaveCarErrLog
    程序集版本: 1.0.0.0
    Win32 版本: 2.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/SaveCarErrLog.DLL
----------------------------------------
SaveSocketStr
    程序集版本: 1.0.0.0
    Win32 版本: 2.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/SaveSocketStr.DLL
----------------------------------------
SaveMeasureDataLog
    程序集版本: 1.0.0.0
    Win32 版本: 2.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/SaveMeasureDataLog.DLL
----------------------------------------
DevExpress.XtraBars.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraBars.v7.1.DLL
----------------------------------------
DevExpress.Utils.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.Utils.v7.1.DLL
----------------------------------------
HY_ILSComm
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/HY_ILSComm.DLL
----------------------------------------
System.Configuration
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
DevExpress.Data.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.Data.v7.1.DLL
----------------------------------------
DevExpress.XtraEditors.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraEditors.v7.1.DLL
----------------------------------------
DevExpress.XtraLayout.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraLayout.v7.1.DLL
----------------------------------------
System.Transactions
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
Accessibility
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1433 (REDBITS.050727-1400)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
DevExpress.XtraGrid.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraGrid.v7.1.DLL
----------------------------------------
DevExpress.XtraCharts.v7.1
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraCharts.v7.1.DLL
----------------------------------------
DevExpress.XtraCharts.v7.1.UI
    程序集版本: 7.1.1.0
    Win32 版本: 7.1.1.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/DevExpress.XtraCharts.v7.1.UI.DLL
----------------------------------------
mscorlib.resources
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.1891 (QFEN-1.050727-1800)
    基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
BarCode
    程序集版本: 1.5.2840.25357
    Win32 版本: 1.5.0.0
    基本代码: file:///F:/testGatherWeight/GatherWeight/bin/Debug/BarCode.DLL
----------------------------------------
System.Windows.Forms.resources
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.42 (RTM.050727-4200)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。例如: <configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>启用 JIT 调试后,任何无法处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。==================================================我按照上面的提示在app.config中添加<system.windows.forms jitDebugging="true" />
但是过了一会程序自动退出,查看系统异常日志提示2012-05-22 11:58:52发生系统异常。
System.IO.IOException: 句柄无效。   在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   在 System.IO.__Error.WinIOError()
   在 System.Threading.EventWaitHandle.Set()
   在 System.Windows.Forms.Control.ThreadMethodEntry.Complete()
   在 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   在 DevExpress.Utils.Win.Hook.ControlWndHook.CallWindowProc(IntPtr pPrevProc, IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
   在 DevExpress.Utils.Win.Hook.ControlWndHook.WindowProc(IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.Run(Form mainForm)
   在 GatherWeight.Program.Main() 位置 F:\testGatherWeight\GatherWeight\Program.cs:行号 29=======================================请问如何解决此问题?

解决方案 »

  1.   

    未处理 System.IO.IOException
      Message="句柄无效。\r\n"
      Source="mscorlib"
      StackTrace:
           在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
           在 System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
           在 System.Console.GetBufferInfo()
           在 System.Console.Clear()
           在 timer.Program.Main()
           在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    我也遇到类似问题。求解呀!