×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

System can't find WinSCPnet.DLL

System can't find WinSCPnet.DLL

System can't find WinSCPnet.DLL

(OP)
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:

CODE --> 4.0

'===================================================================================================================================
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 ... ponder
Secondly, why this same function work in one program (with identical entry in the Reference section!) and does not in another?! mad
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

RE: System can't find WinSCPnet.DLL

Please read the error carefully - it references winscp.exe, not winscpnet.dll

That's your starting point ...

RE: System can't find WinSCPnet.DLL

(OP)

Quote (StrongM)

it references winscp.exe, not winscpnet.dll
As I've stated in my original post, it's exactly what I can't understand: why it looks for EXE?

Regards,

Ilya

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close