Hello,
I have been using the SSH.Net library to connect to a remote SSH server to establish a DB connection between a VB client software and MySQL server. Everything works fine except sometimes the following exception is unhandled and crashes the application:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
at Microsoft.Win32.Win32Native.SetEvent(Microsoft.Win32.SafeHandles.SafeWaitHandle)
at System.Threading.EventWaitHandle.Set()
at Renci.SshNet.Channels.ChannelDirectTcpip.OnErrorOccured(System.Exception)
at Renci.SshNet.Channels.Channel.Session_ErrorOccured(System.Object, Renci.SshNet.Common.ExceptionEventArgs)
at System.EventHandler`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.__Canon)
at Renci.SshNet.Session.RaiseError(System.Exception)
at Renci.SshNet.Session.MessageListener()
at Renci.SshNet.Session.<Connect>b__4()
at Renci.SshNet.Session+<>c__DisplayClass3d.<ExecuteThread>b__3c(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.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Any idea what could be the cause?
I am running with the code base downloaded on March 16th 2014.
My connect, disconnect code is pretty straightforward:
client = Nothing
client = New SshNet.SshClient(_host, _port, _user, key)
client.Connect()
portfw = Nothing
portfw = New SshNet.ForwardedPortLocal("localhost", 33306, "localhost", 3306)
client.AddForwardedPort(portfw)
portfw.Start()
...................
If isStarted Then
portfw.Stop()
End If
If isConnected Then
client.RemoveForwardedPort(portfw)
client.Disconnect()
End If
Many thanks,
Phil
I have been using the SSH.Net library to connect to a remote SSH server to establish a DB connection between a VB client software and MySQL server. Everything works fine except sometimes the following exception is unhandled and crashes the application:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
at Microsoft.Win32.Win32Native.SetEvent(Microsoft.Win32.SafeHandles.SafeWaitHandle)
at System.Threading.EventWaitHandle.Set()
at Renci.SshNet.Channels.ChannelDirectTcpip.OnErrorOccured(System.Exception)
at Renci.SshNet.Channels.Channel.Session_ErrorOccured(System.Object, Renci.SshNet.Common.ExceptionEventArgs)
at System.EventHandler`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.__Canon)
at Renci.SshNet.Session.RaiseError(System.Exception)
at Renci.SshNet.Session.MessageListener()
at Renci.SshNet.Session.<Connect>b__4()
at Renci.SshNet.Session+<>c__DisplayClass3d.<ExecuteThread>b__3c(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.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Any idea what could be the cause?
I am running with the code base downloaded on March 16th 2014.
My connect, disconnect code is pretty straightforward:
client = Nothing
client = New SshNet.SshClient(_host, _port, _user, key)
client.Connect()
portfw = Nothing
portfw = New SshNet.ForwardedPortLocal("localhost", 33306, "localhost", 3306)
client.AddForwardedPort(portfw)
portfw.Start()
...................
If isStarted Then
portfw.Stop()
End If
If isConnected Then
client.RemoveForwardedPort(portfw)
client.Disconnect()
End If
Many thanks,
Phil