是什么导致了这个套接字错

时间:2015-02-17 09:19:09

标签: c# sockets

我偶尔会在运行App的多个实例的系统上遇到此错误。应用程序实例“Cobra”也在同一系统上与控制应用程序“SLotManager”通信。

但是每隔几天我就会收到一个套接字错误。任何人都可以告诉我错误的来源吗?

这是来自事件查看器:

> Application: Cobra.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception.
> Exception Info: System.ObjectDisposedException Stack: at
> System.Net.Sockets.Socket.get_RemoteEndPoint() at
> IPCspace.IPCInitiator.SendMessage(Connection, System.String) at
> IPCspace.IPCInitiator.SendMessageAllClients(System.String) at
> ModelInitiator.ModelInitiator.SendCommand(System.String,
> System.String) at ModelInitiator.ModelInitiator.Monitor(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.TimerQueueTimer.CallCallback() at
> System.Threading.TimerQueueTimer.Fire() at
> System.Threading.TimerQueue.FireNextTimers()

Version=1
EventType=CLR20r3
EventTime=130686364607835754
ReportType=2
Consent=1
ReportIdentifier=a10dbbdb-b681-11e4-91ca-c81f66e67335
IntegratorReportIdentifier=a10dbbda-b681-11e4-91ca-c81f66e67335
Response.type=4
Sig[0].Name=Problem Signature 01
Sig[0].Value=cobra.exe
Sig[1].Name=Problem Signature 02
Sig[1].Value=1.0.0.0
Sig[2].Name=Problem Signature 03
Sig[2].Value=54dd2a46
Sig[3].Name=Problem Signature 04
Sig[3].Value=System
Sig[4].Name=Problem Signature 05
Sig[4].Value=4.0.30319.18408
Sig[5].Name=Problem Signature 06
Sig[5].Value=52311185
Sig[6].Name=Problem Signature 07
Sig[6].Value=2f0c
Sig[7].Name=Problem Signature 08
Sig[7].Value=a8
Sig[8].Name=Problem Signature 09
Sig[8].Value=System.ObjectDisposedException
DynamicSig[1].Name=OS Version
DynamicSig[1].Value=6.1.7601.2.1.0.272.7
DynamicSig[2].Name=Locale ID
DynamicSig[2].Value=1033
DynamicSig[22].Name=Additional Information 1
DynamicSig[22].Value=f381
DynamicSig[23].Name=Additional Information 2
DynamicSig[23].Value=f3815298bc190454bbdc78c9bec74cef
DynamicSig[24].Name=Additional Information 3
DynamicSig[24].Value=5ad8
DynamicSig[25].Name=Additional Information 4
DynamicSig[25].Value=5ad8d1f01875b609cf763e8953cf4b21
UI[2]=C:\Projects\CobraPROD\CobraPROD\bin\x64\My64\Cobra.exe
UI[3]=CobraApp has stopped working
UI[4]=Windows can check online for a solution to the problem.
UI[5]=Check online for a solution and close the program
UI[6]=Check online for a solution later and close the program
UI[7]=Close the program
LoadedModule[0]=C:\Projects\CobraPROD\CobraPROD\bin\x64\My64\Cobra.exe
LoadedModule[1]=C:\Windows\SYSTEM32\ntdll.dll
LoadedModule[2]=C:\Windows\SYSTEM32\MSCOREE.DLL
LoadedModule[3]=C:\Windows\system32\KERNEL32.dll
LoadedModule[4]=C:\Windows\system32\KERNELBASE.dll
LoadedModule[5]=C:\Windows\system32\ADVAPI32.dll
LoadedModule[6]=C:\Windows\system32\msvcrt.dll
LoadedModule[7]=C:\Windows\SYSTEM32\sechost.dll
LoadedModule[8]=C:\Windows\system32\RPCRT4.dll
LoadedModule[9]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
LoadedModule[10]=C:\Windows\system32\SHLWAPI.dll
LoadedModule[11]=C:\Windows\system32\GDI32.dll
LoadedModule[12]=C:\Windows\system32\USER32.dll
LoadedModule[13]=C:\Windows\system32\LPK.dll
LoadedModule[14]=C:\Windows\system32\USP10.dll
LoadedModule[15]=C:\Windows\system32\IMM32.DLL
LoadedModule[16]=C:\Windows\system32\MSCTF.dll
LoadedModule[17]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
LoadedModule[18]=C:\Windows\system32\MSVCR110_CLR0400.dll
LoadedModule[19]=C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\abf62e6545d2802fc60286678a67e6bf\mscorlib.ni.dll
LoadedModule[20]=C:\Windows\system32\ole32.dll
LoadedModule[21]=C:\Windows\system32\CRYPTBASE.dll
LoadedModule[22]=C:\Program Files (x86)\TeamViewer\Version9\tv_x64.dll
LoadedModule[23]=C:\Windows\system32\VERSION.dll
LoadedModule[24]=C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_a4d3b9377117c3df\COMCTL32.dll
LoadedModule[25]=C:\Windows\system32\SHELL32.dll
LoadedModule[26]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
LoadedModule[27]=C:\Windows\system32\OLEAUT32.dll
LoadedModule[28]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System\4d4a15d5d7968df7dedd4cf853848d90\System.ni.dll
LoadedModule[29]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Drawing\7926c26400ff262c7fc48b729377085b\System.Drawing.ni.dll
LoadedModule[30]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Windows.Forms\4764e3995ebd7b6b438eef937cde1332\System.Windows.Forms.ni.dll
LoadedModule[31]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Configuration\13bb14bb88e6c577c79001039d678bbd\System.Configuration.ni.dll
LoadedModule[32]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Xml\fa4b9cda7a89969191429507a934c352\System.Xml.ni.dll
LoadedModule[33]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\nlssorting.dll
LoadedModule[34]=C:\Windows\system32\uxtheme.dll
LoadedModule[35]=C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_fa396087175ac9ac\comctl32.dll
LoadedModule[36]=C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.18455_none_2b283fd671e9bf4d\gdiplus.dll
LoadedModule[37]=C:\Windows\system32\CRYPTSP.dll
LoadedModule[38]=C:\Windows\system32\rsaenh.dll
LoadedModule[39]=C:\Windows\system32\RpcRtRemote.dll
LoadedModule[40]=C:\Windows\system32\ws2_32.dll
LoadedModule[41]=C:\Windows\system32\NSI.dll
LoadedModule[42]=C:\Windows\system32\mswsock.dll
LoadedModule[43]=C:\Windows\System32\wshtcpip.dll
LoadedModule[44]=C:\Windows\System32\wship6.dll
LoadedModule[45]=C:\Windows\system32\NLAapi.dll
LoadedModule[46]=C:\Windows\system32\napinsp.dll
LoadedModule[47]=C:\Windows\system32\DNSAPI.dll
LoadedModule[48]=C:\Windows\System32\winrnr.dll
LoadedModule[49]=C:\Windows\system32\IPHLPAPI.DLL
LoadedModule[50]=C:\Windows\system32\WINNSI.DLL
LoadedModule[51]=C:\Windows\System32\fwpuclnt.dll
LoadedModule[52]=C:\Windows\system32\rasadhlp.dll
LoadedModule[53]=C:\Windows\system32\dwmapi.dll
LoadedModule[54]=C:\Windows\assembly\NativeImages_v4.0.30319_64\System.Core\1d513cb1b284a419e8b3df381ce7f270\System.Core.ni.dll
LoadedModule[55]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll
FriendlyEventName=Stopped working
ConsentKey=xxxxxxx
AppName=CobraApp
AppPath=C:\Projects\CobraPROD\CobraPROD\bin\x64\My64\Cobra.exe

1 个答案:

答案 0 :(得分:0)

在您的函数ModelInitiator.SendCommand中,您可能正在使用已处置或使用已经处置的连接的IPCInitiator重新使用。您似乎正在使用多线程系统,并且在您发送消息之前,其他线程上的某些内容可能会关闭连接(连接上的错误等)。

在发送消息之前,您可以检查连接的状态。您可以通过添加try catch块来处理异常。