Colleagues,
While the system sees the DLL in subject for one project/program, it cannot see it within another, and I can't figure out why.
Here's the code:
Here's the message I get when run in debug mode:
For starters, I cannot understand why it looks for WinSCP.EXE instead of WinSCPnet.DLL ...
Secondly, why this same function work in one program (with identical entry in the Reference section!) and does not in another?!
I exhausted all my imagination of what can be done to alleviate this nuisance: put (and re-referenced) this DLL into the \bin\Debug\ subdir, tried to place EXE into References (wouldn't take it), removed references to DLL and added back again... nothing helped.
So, if anyone here can help me - it'll be greatly appreciated!
TIA!
Regards,
Ilya
While the system sees the DLL in subject for one project/program, it cannot see it within another, and I can't figure out why.
Here's the code:
Code:
'===================================================================================================================================
Public Function WinSFTP_Send_CTC(ByVal tcHostName As String, ByVal tcUserName As String, ByVal tcPW As String, _
ByVal SSHKFP As String, ByVal tcSrcDir As String, ByVal tcSrcFileName As String, _
ByVal tcDstDir As String) As Boolean
'===================================================================================================================================
' Purpose : Transfers files from one place to another using SFTP.
' Description : .
' Parameters : .
' Side effects : None.
' Notes : 1. Requires full path to the WinCSPNet.DLL in the Project's References subsection.
' 2. Verbose on error if run in VS's IDE, silent otherwise.
' 3. No parameters' verification, presumed valid (errs if not, and then see p. 2).
'===================================================================================================================================
Dim llRet As Boolean = True, lcLogStr As String = "", lcErrStr As String = "", loSessionOptions As New SessionOptions, _
lcDstDir As String = AddBackSlash(tcDstDir)
Dim liWildCardChrCnt As Int16 = GetChrCount("*", tcSrcFileName), lcFullPath2File As String = "", lcJustFName As String
Dim laFiles(0) As String
If liWildCardChrCnt > 0 Then
laFiles = Directory.GetFiles(tcSrcDir)
Else
laFiles(0) = AddBackSlash(tcSrcDir) & tcSrcFileName
End If
' Array laFiles[] contains now full path to each of the source files in the source directory
With loSessionOptions
.Protocol = Protocol.Sftp
.HostName = tcHostName
.UserName = tcUserName
.Password = tcPW
'.SshHostKeyFingerprint = SSHKFP
.GiveUpSecurityAndAcceptAnySshHostKey = True
End With
Using loSession As New Session
Dim loTransferResult As TransferOperationResult, loTransferOptions As New TransferOptions
' Connect
loSession.Open(loSessionOptions)
If Not loSession.Opened Then
llRet = False
lcLogStr = lcLogStr & Now.ToString("yyyy-MM-dd HH:mm:ss") & ": Session.Open(SessionOptions) failed!" & vbCrLf & Space(21) & _
"Program quits." & vbCrLf
Write2Log(gcLogFile, lcLogStr, True)
If glDevelop Then
MsgBox("Session.Open(SessionOptions) failed!" & vbCrLf & "Program quits.", MsgBoxStyle.Critical, "Session Open failed!")
End If 'glDevelop
Return llRet
End If 'Not loSession.Opened
' Upload files
loTransferOptions.TransferMode = TransferMode.Binary
Try
For Each lcFullPath2File In laFiles
lcJustFName = Path.GetFileName(lcFullPath2File)
loTransferResult = loSession.PutFiles(lcFullPath2File, lcDstDir & lcJustFName, False, loTransferOptions)
If Not loTransferResult.IsSuccess Then
llRet = False
lcLogStr = lcLogStr & Now.ToString("yyyy-MM-dd HH:mm:ss") & ": transfer of the file" & lcFullPath2File & _
vbCrLf & Space(21) & "to " & tcDstDir & " failed!" & vbCrLf & Space(21) & "Program quits." & vbCrLf
Write2Log(gcLogFile, lcLogStr, True)
If glDevelop Then
MsgBox("Transfer of the file " & lcFullPath2File & " to " & tcDstDir & " failed!" & vbCrLf & "Program quits.", _
MsgBoxStyle.Critical, "File transfer failed!")
End If
Exit For
End If
Next
Catch loErr As Exception
lcLogStr = lcLogStr & Now.ToString("yyyy-MM-dd HH:mm:ss") & ": ERROR OCCURED while transfering file" & lcFullPath2File & _
vbCrLf & Space(21) & "to " & tcDstDir & "!" & vbCrLf & Space(21) & loErr.Message & _
vbCrLf & Space(21) & "Occured in " & vbCrLf & Space(21) & loErr.Source & vbCrLf & Space(21) & _
loErr.StackTrace & vbCrLf & Space(21) & "Program quits." & vbCrLf
llRet = False
Write2Log(gcLogFile, lcLogStr, True)
If glDevelop Then
lcErrStr = "ERROR OCCURED!" & vbCrLf & loErr.Message & vbCrLf & "Occured in " & vbCrLf & loErr.Source & vbCrLf & _
loErr.StackTrace & vbCrLf & "Program quits."
MsgBox(lcErrStr, MsgBoxStyle.Critical, gcAppName & ": WinCSP failed!")
End If
End Try
loSession.Close()
loSession.Dispose()
End Using
Return llRet
End Function
'===================================================================================================================================
Here's the message I get when run in debug mode:
For starters, I cannot understand why it looks for WinSCP.EXE instead of WinSCPnet.DLL ...
Secondly, why this same function work in one program (with identical entry in the Reference section!) and does not in another?!
I exhausted all my imagination of what can be done to alleviate this nuisance: put (and re-referenced) this DLL into the \bin\Debug\ subdir, tried to place EXE into References (wouldn't take it), removed references to DLL and added back again... nothing helped.
So, if anyone here can help me - it'll be greatly appreciated!
TIA!
Regards,
Ilya