【发布时间】:2013-12-12 17:47:46
【问题描述】:
我有一个 Windows 窗体,它当前正在从串行端口获取数据并获取数据。每隔一段时间,数据会保存在 xml 中,然后保存到 sql 中。该程序有时会工作,但有时会崩溃。这是错误的事件日志。
Application: appname
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TimeoutException
Stack:
at System.IO.Ports.SerialPort.ReadTo(System.String)
at System.IO.Ports.SerialPort.ReadLine()
at appname.frmParameters.mySerialPort_DataReceived(System.Object, System.IO.Ports.SerialDataReceivedEventArgs)
at System.IO.Ports.SerialPort.CatchReceivedEvents(System.Object, System.IO.Ports.SerialDataReceivedEventArgs)
at System.IO.Ports.SerialStream+EventLoopRunner.CallReceiveEvents(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
感谢您的帮助
【问题讨论】:
-
我们需要程序崩溃的源代码。如果您还将错误消息放入描述中将不胜感激(例如,如果您的异常被称为 e,您必须添加 e.Message、e.Source 和 e.StackTrace
-
在我目前的情况下,我无法确定错误位置,因为此事件失败错误来自已编译的 .exe。是否有一个整体 wrap 命令可用于将错误输出到日志文件中?我无法从源代码运行它,需要编译它来测试它。
标签: c# vb.net winforms error-handling crash