如何理解事件日志,以确定为什么.net系统在一段时间后崩溃



我用c#开发了一个需要全天候运行的软件。在这里,我使用Socket连接与服务器连接,并获得响应,因为软件正在通过Socket将用户消息从他们的手机传输到Facebook。

之前它工作得很好,但因为几天它是崩溃后运行几个小时。所以当我检查我的事件日志时,我发现下面的日志对我来说很不熟悉:

Error occurred at: 5:05:11 AM

  Faulting application name: USSD_FB.exe, version: 1.0.0.0, time stamp: 0x5382ad72
  Faulting module name: KERNELBASE.dll, version: 6.1.7601.17965, time stamp: 0x506dcae6
  Exception code: 0xe0434352
  Fault offset: 0x000000000000bccd
  Faulting process id: 0x3618
  Faulting application start time: 0x01cf79ea973870e8
  Faulting application path: E:USSD_FBUSSD_FBbinDebugUSSD_FB.exe
  Faulting module path: C:Windowssystem32KERNELBASE.dll
  Report Id: 96e446f9-e5e2-11e3-8ae7-0015175fd6c0

这个错误发生在5:05:10 AM:

  Application: USSD_FB.exe
  Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: System.Net.Sockets.SocketException
  Stack:
  at System.Net.Sockets.Socket.EndReceive(System.IAsyncResult)
  at USSD_FB.frmBulk.ReceiveCallback(System.IAsyncResult)
  at System.Net.LazyAsyncResult.Complete(IntPtr)
  at System.Threading.ExecutionContext.runTryCode(System.Object)
  at  System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
 at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
 at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
 at System.Net.ContextAwareResult.Complete(IntPtr)
 at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
 at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

如果有人能帮助我理解上面的事件日志,我将非常感激,这可能有助于我解决我的问题。

根据您的堆栈跟踪,会发生以下情况:

  1. 你调用Socket.BeginReceive,并给它一个CallBack来调用一旦它完成接收你的数据
  2. 你的回调被调用。在回调中调用EndReceive并将IAsyncResult回调传递给它
  3. EndReceive尝试访问流,但是发生异常,这意味着Socket发生了一些事情。你没有在你的回调中catchSocketException,这会导致进程崩溃。

from MSDN, Socket.EndReceive:

如果你收到一个SocketException,使用SocketException。属性获取特定的错误码。获取此代码后,请参阅MSDN库中的Windows Sockets版本2 API错误代码文档,以获取错误

的详细描述。

您需要用catch (SocketException)子句包装yourUSSD_FB.frmBulk.ReceiveCallback(System.IAsyncResult)方法并处理异常

相关内容

  • 没有找到相关文章

最新更新