been using ediFTPnet/PRO for a few weeks now, with no problems at all.
However, there seems to be no way to tell when a network is unreachable. The code errors out with an unhandled NullReferenceException:
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 10/4/2007
Time: 10:15:22 AM
User: N/A
Computer: CLP101732
Description:
EventType clr20r3, P1 clp_iris.exe, P2 1.0.2826.27445, P3 46fc0f68, P4 edtftpnetpro, P5 4.2.0.0, P6 46957031, P7 1521, P8 0, P9 system.nullreferenceexception, P10 NIL.
i have a try block like this:
Dim connected As Boolean = False
Try
If CertificateExists() Then
'connect to FTP
If sftp Is Nothing Then
sftp = New SecureFTPConnection
End If
'set settings omitted
sftp.Connect()
connected = True
End If
Else
MessageBox.Show("The Certificate required for this application - clpftp.cer - is not installed", _
"Certificate Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As System.NullReferenceException
connected = False
logger.ErrorException("Error", ex)
Catch ex As Exception
logger.ErrorException("Error", ex)
connected = False
Finally
End Try
Return connected
If i pull my network plug and try to connect, the application throws a NullReferenceException with an object does not exist. It does not fall to the catch. if i am in debug mode, the code stops on this line:
sftp.Connect()
and shows me the NullReferenceException. it never drops to either of the Catch statements
Its as if the sftp object itself is destroyed when it cannot reach the network.
I got around this by coding this function:
Private Function CanSeeFTP() As Boolean
Dim client As New TcpClient()
Dim ret As Boolean = False
Try
client.Connect(Me.uxFTPServer.Text, Me.uxFTPPort.Text)
If client.Connected Then
ret = True
client.Client.Disconnect(False)
Else
ret = False
End If
Catch ex As Exception
ret = False
End Try
Return ret
End Function
and adding an If CanSeeFTP() Then prior to connecting:
If CertificateExists() Then
If CanSeeFTP() Then
'connect to FTP
If sftp Is Nothing Then
sftp = New SecureFTPConnection
End If
Is there any functionality built into ediFTPnet/PRO to notify me that the server is unreachable?