hannes.schneider
Hello!
We use smartftp lib with vb6 and have some troubles using sftp mode in the final exe (ftp is working fine). Everthing is working fine in debug mode and we can connect to ftp as well as to sftp. But when we compile the vb program it crashes on connecting (see code line with crash) to sftp server :
___________________ EXAMPLE CODE begin___________________
Option Explicit
Public Event Status(sText As String) 'Liefer kontinuierlich Informationen über den Zustand der Verbindung
Private Const M_DEF_CONNECTION_MODE = 1 ' SFTP ist standard
Private Const M_DEF_TIMEOUT = 50 ' Standard Timeout
Private Const M_DEF_HOSTPATH = "/" ' Root folder beim Verbinden
Private Const M_DEF_PORT = 22 ' Standard port to use
Private Const M_DUMMY_SIZE_MIN = 100 ' minimum size of dummy file (
Private Const M_DUMMY_SIZE_MAX = 2000 ' maximum size of dummy file (
Public Enum FTPConnectionMode
FTPConnectionEnum = 0 'ConnectionEnum
SFTPConnectionEum = 1
End Enum
Private objFTP As Object 'generische Object
Private WithEvents objFTPConnection As sfFTPLib.FTPConnectionSTA 'löst FTP Events aus
Private WithEvents objSFTPConnection As sfFTPLib.SFTPConnection 'löst SFTP Events aus
Private objGlobal As sfFTPLib.Global 'Für Lizensierung
Private mlConnectionMode As FTPConnectionMode 'Mode: SFTP || FTP
Private msHostName As String 'Host name
Private miPort As Integer 'Port (21=ftp, 22=sftp)
Private msUserName As String 'UserName
Private msPassword As String 'Passwort
Private msHostPath As String 'Aktueller Pfad am server
Private mbConnected As Boolean 'Verbindung hergestellt?
Private msLogFilePath As String 'Log file pfad (standard = application path)
Private miTimeout As Integer 'Timeout für verbindung
Private Sub Command1_Click()
On Error GoTo ErrorHandler
Dim strKey As String
mlConnectionMode = M_DEF_CONNECTION_MODE
msHostName = vbNullString
miPort = M_DEF_PORT
msUserName = vbNullString
msPassword = vbNullString
msHostPath = M_DEF_HOSTPATH
mbConnected = False
msLogFilePath = App.Path & "\" & "SFTPlog.log"
miTimeout = M_DEF_TIMEOUT
Set objGlobal = CreateObject("sfFTPLib.Global")
'SmartFTP License
strKey = strKey & "<?xml version=""1.0"" ?>" & vbCrLf
strKey = strKey & "<License>" & vbCrLf
strKey = strKey & "<Version>2.0</Version>" & vbCrLf
strKey = strKey & "<Id></Id>" & vbCrLf
strKey = strKey & "<Name></Name>" & vbCrLf
strKey = strKey & "<Email>licensing@avl.com</Email>" & vbCrLf
strKey = strKey & "<Company>AVL List GmbH</Company>" & vbCrLf
strKey = strKey & "<Product>SmartFTP FTP Library</Product>" & vbCrLf
strKey = strKey & "<Features>" & vbCrLf
strKey = strKey & "<Feature>FTP</Feature>" & vbCrLf
strKey = strKey & "<Feature>SFTP</Feature>" & vbCrLf
strKey = strKey & "</Features>" & vbCrLf
strKey = strKey & "<Users>1</Users>" & vbCrLf
strKey = strKey & "<Maintenance>2009-10-28</Maintenance>" & vbCrLf
strKey = strKey & "<Issue>2008-10-28</Issue>" & vbCrLf
strKey = strKey & "<Signature>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Signature>" & vbCrLf
strKey = strKey & "</License>" & vbCrLf
If objGlobal.LoadLicenseKeyData(strKey) = False Then Debug.Print ("SFTPCLass: License not valid!"); False
Debug.Print ("SFTPCLass: Version " & objGlobal.Version)
Set objSFTPConnection = CreateObject("sfFTPLib.SFTPConnection")
objSFTPConnection.Host = "server.name"
objSFTPConnection.Port = "22"
objSFTPConnection.Username = "USERNAME"
objSFTPConnection.Password = "PW"
objSFTPConnection.LogFile = msLogFilePath
objSFTPConnection.Timeout = miTimeout
'//////////////////////////////////////////////////////// CRASH in this LINE ////////////////////////////////////////////////////////////////
If objSFTPConnection.Connect = sfFTPLib.enumError.ftpErrorSuccess Then mbConnected = True Else mbConnected = False
Exit Sub
ErrorHandler:
Debug.Assert False
End Sub
Private Sub objSFTPConnection_OnStatus(ByVal t As sfFTPLib.enumStatusEventType, ByVal bstrText As String)
Debug.Print bstrText
End Sub
______________________________ CODE END _______________________________________
regards
Hannes
We use smartftp lib with vb6 and have some troubles using sftp mode in the final exe (ftp is working fine). Everthing is working fine in debug mode and we can connect to ftp as well as to sftp. But when we compile the vb program it crashes on connecting (see code line with crash) to sftp server :
___________________ EXAMPLE CODE begin___________________
Option Explicit
Public Event Status(sText As String) 'Liefer kontinuierlich Informationen über den Zustand der Verbindung
Private Const M_DEF_CONNECTION_MODE = 1 ' SFTP ist standard
Private Const M_DEF_TIMEOUT = 50 ' Standard Timeout
Private Const M_DEF_HOSTPATH = "/" ' Root folder beim Verbinden
Private Const M_DEF_PORT = 22 ' Standard port to use
Private Const M_DUMMY_SIZE_MIN = 100 ' minimum size of dummy file (
Private Const M_DUMMY_SIZE_MAX = 2000 ' maximum size of dummy file (
Public Enum FTPConnectionMode
FTPConnectionEnum = 0 'ConnectionEnum
SFTPConnectionEum = 1
End Enum
Private objFTP As Object 'generische Object
Private WithEvents objFTPConnection As sfFTPLib.FTPConnectionSTA 'löst FTP Events aus
Private WithEvents objSFTPConnection As sfFTPLib.SFTPConnection 'löst SFTP Events aus
Private objGlobal As sfFTPLib.Global 'Für Lizensierung
Private mlConnectionMode As FTPConnectionMode 'Mode: SFTP || FTP
Private msHostName As String 'Host name
Private miPort As Integer 'Port (21=ftp, 22=sftp)
Private msUserName As String 'UserName
Private msPassword As String 'Passwort
Private msHostPath As String 'Aktueller Pfad am server
Private mbConnected As Boolean 'Verbindung hergestellt?
Private msLogFilePath As String 'Log file pfad (standard = application path)
Private miTimeout As Integer 'Timeout für verbindung
Private Sub Command1_Click()
On Error GoTo ErrorHandler
Dim strKey As String
mlConnectionMode = M_DEF_CONNECTION_MODE
msHostName = vbNullString
miPort = M_DEF_PORT
msUserName = vbNullString
msPassword = vbNullString
msHostPath = M_DEF_HOSTPATH
mbConnected = False
msLogFilePath = App.Path & "\" & "SFTPlog.log"
miTimeout = M_DEF_TIMEOUT
Set objGlobal = CreateObject("sfFTPLib.Global")
'SmartFTP License
strKey = strKey & "<?xml version=""1.0"" ?>" & vbCrLf
strKey = strKey & "<License>" & vbCrLf
strKey = strKey & "<Version>2.0</Version>" & vbCrLf
strKey = strKey & "<Id></Id>" & vbCrLf
strKey = strKey & "<Name></Name>" & vbCrLf
strKey = strKey & "<Email>licensing@avl.com</Email>" & vbCrLf
strKey = strKey & "<Company>AVL List GmbH</Company>" & vbCrLf
strKey = strKey & "<Product>SmartFTP FTP Library</Product>" & vbCrLf
strKey = strKey & "<Features>" & vbCrLf
strKey = strKey & "<Feature>FTP</Feature>" & vbCrLf
strKey = strKey & "<Feature>SFTP</Feature>" & vbCrLf
strKey = strKey & "</Features>" & vbCrLf
strKey = strKey & "<Users>1</Users>" & vbCrLf
strKey = strKey & "<Maintenance>2009-10-28</Maintenance>" & vbCrLf
strKey = strKey & "<Issue>2008-10-28</Issue>" & vbCrLf
strKey = strKey & "<Signature>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Signature>" & vbCrLf
strKey = strKey & "</License>" & vbCrLf
If objGlobal.LoadLicenseKeyData(strKey) = False Then Debug.Print ("SFTPCLass: License not valid!"); False
Debug.Print ("SFTPCLass: Version " & objGlobal.Version)
Set objSFTPConnection = CreateObject("sfFTPLib.SFTPConnection")
objSFTPConnection.Host = "server.name"
objSFTPConnection.Port = "22"
objSFTPConnection.Username = "USERNAME"
objSFTPConnection.Password = "PW"
objSFTPConnection.LogFile = msLogFilePath
objSFTPConnection.Timeout = miTimeout
'//////////////////////////////////////////////////////// CRASH in this LINE ////////////////////////////////////////////////////////////////
If objSFTPConnection.Connect = sfFTPLib.enumError.ftpErrorSuccess Then mbConnected = True Else mbConnected = False
Exit Sub
ErrorHandler:
Debug.Assert False
End Sub
Private Sub objSFTPConnection_OnStatus(ByVal t As sfFTPLib.enumStatusEventType, ByVal bstrText As String)
Debug.Print bstrText
End Sub
______________________________ CODE END _______________________________________
regards
Hannes