我有一個運行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>
我們需要看代碼來幫助你 – Baz1nga
有很多組件依次運行,所以不可能發佈代碼。 –
我沒有做任何套接字編程,第三方DLL可能使用套接字來連接SFTP。 –