我有一个 24*7 运行的 Windows 服务。该服务使用 Renci.SshNet(第三方 dll)连接到 sftp 服务器并下载和上传文件。
我在事件查看器中获得了以下信息。我检查了日志文件,发现当这个错误出现时,与 SFTP 服务器相关的代码没有运行。
我已经在 try catch 块中编写了所有代码,因此每个错误都记录到日志文件中。
由于此错误,Windows 服务停止。
我想知道这个问题的根本原因以及如何修改代码,这样我的服务就不会再次自动停止。
Log Name: Application
Source: .NET Runtime
Date: 5/12/2012 10:49:12 AM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: FedEx-EDI-01
Description:
Application: Ess.SupplyChainService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
Stack:
at Renci.SshNet.Session.WaitHandle(System.Threading.WaitHandle)
at Renci.SshNet.Channels.Channel.Dispose(Boolean)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean)
at Renci.SshNet.Channels.Channel.Dispose()
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Finalize()
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2012-05-12T14:49:12.000Z" />
<EventRecordID>3723</EventRecordID>
<Channel>Application</Channel>
<Computer>FedEx-EDI-01</Computer>
<Security />
</System>
<EventData>
<Data>Application: Ess.SupplyChainService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
Stack:
at Renci.SshNet.Session.WaitHandle(System.Threading.WaitHandle)
at Renci.SshNet.Channels.Channel.Dispose(Boolean)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean)
at Renci.SshNet.Channels.Channel.Dispose()
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Finalize()
</Data>
</EventData>
</Event>