Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Renci.SshNet.Common.SshConnectionException
Stack:
at Renci.SshNet.Session.SendMessage(Renci.SshNet.Messages.Message)
at Renci.SshNet.Channels.Channel.SendMessage(Renci.SshNet.Messages.Connection.ChannelCloseMessage)
at Renci.SshNet.Channels.Channel.Close(Boolean)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean)
at Renci.SshNet.Channels.Channel.Dispose(Boolean)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Finalize()
__This occurred just over 60 seconds _after_ the Dispose method on SftpClient was called which generated a very similar exception (handled and logged by my code):__
2013-02-16 15:41:32.9693 Error SftpFileTransfer Renci.SshNet.Common.SshConnectionException,Client not connected., at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.SendMessage(ChannelCloseMessage message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Dispose()
at BusinessObjects.SftpFileTransfer.DownloadFiles()
__It looks like ~SubsystemSession() is causing an attempt to send a message over the channel(!) due to the chaining of calls to the various Dispose() methods.__
Comments: ** Comment from web user: SergeyOsten **
I have same problem .
public void Put()
{
using (var sftp = new SftpClient("127.0.0.1", 2222, "**", "123"))
{
try
{
sftp.Connect();
using (var streamFile = File.OpenRead(@"C:\temp\1\as1d_6.txt"))
{
sftp.UploadFile(streamFile, "/qq/1s.txt");
}
sftp.Disconnect();
}
catch (Exception ex)
{
textBox1.Text = ex.Message;
}
finally
{
if (sftp != null)
{
sftp.Disconnect();
sftp.Dispose();
}
}
}
}
when sftp server down I have unhadled exception
shNet.Common.SshConnectionException: Client not connected.
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.SendMessage(ChannelCloseMessage message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Finalize()