Topic "Error: WinSCP. NET Assembly"

Author Message
ctapia
[View user's profile]

Joined: 2012-01-20
Posts: 1
Good morning,
I need a help, I am trying to download some files from an SFTP connection, as I read there is "WinSCP. NET Assembly winscp.dll" to program in C #. NET, I found only one in the FAR, but when I try to add it as reference to my C # project. NET displays an error

Code:
---------------------------
Microsoft Visual Studio
---------------------------
A reference to 'D:\CTAPIA\Plantillas\NET\LeerSFTP\WindowsFormsApplication1\WindowsFormsApplication1\WinSCP\WinSCP.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.



I want to do the following, Example:

http://winscp.net/eng/docs/library_session_getfiles#example

thanks,
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
WinSCP.dll in FAR package in plugin to FAR file manager.

WinSCP .NET assembly was not release yet. It will be included in 5.0.6 beta, coming out in few weeks.
_________________
Martin Prikryl
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
Martin,

First I would like to thank you for the WinSCP software and the abundant documentation, it has simplified my development when doing sFTP transfers.

Second - If there is any way I could convince you [read: beg....please Wink ] to release a stub or class we could code against now it would be much appreciated. I would even be open to being a guinea pig (a.k.a. Beta User) until the WinSCP.dll stablizes. This would provide the opportunity for some of us to know the methods, properties, etc. and we can fill it in with our own code for now but just replace with your .dll when the day arrives.

All the best,

j0se
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?
_________________
Martin Prikryl
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
Martin, email sent about a minute ago.

All the best,

Joe
MsMaria

Guest


Can I too request for a copy of the .NET library please? Email msmaria0503 at gmail com. Thank you!
joelrb
[View user's profile]

Joined: 2012-02-02
Posts: 1
Location: Philippines
prikryl wrote:
I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?


Hi Martin,

I've been using WinSCP in .Net as described here: http://winscp.net/eng/docs/guide_dotnet.

I also want to try the .Net Assembly (DLL). Can you send me a preview so I can test also? I'll give feedback on my use of it. Please send to joelrb at gmail.com

Many thanks!

Joel
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
I have sent an email to all of you. Looking forward for your feedback.
flavio66
[View user's profile]

Joined: 2012-02-03
Posts: 1
Location: Carrara - Italy
Hi Martin,
great job!
I'm writing a internal tool and i need to transfer files over ssh.
I'm using "SFTP file transfers in .NET" as a base but if i could have a preview of the DLL it would be a great improvement: could you send me to lodoli at comune.carrara.ms.it ?.
I'll return all feedback from my work.

Thanks a lot

Flavio
rjl
[View user's profile]

Joined: 2012-02-03
Posts: 1
Location: Copenhagen, Denmark
Can I have a try at this beta aswell?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
I have emailed you too.
ronwello
[View user's profile]

Joined: 2012-02-08
Posts: 2
Location: United States
Could I have a go with the preview of this assembly as well? I'm very interested in it. Thanks. Good work on winscp, by the way.
andys
[View user's profile]

Joined: 2012-02-08
Posts: 3
Hello, would it also be possible for me to get the DLL for testing purposes
Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
I'm in a middle of rewrite of the assembly. Will contact you once that's done.
_________________
Martin Prikryl
ronwello
[View user's profile]

Joined: 2012-02-08
Posts: 2
Location: United States
prikryl wrote:
I'm in a middle of rewrite of the assembly. Will contact you once that's done.


Thanks! I'm very much looking forward to it.
Jaryth

Guest


prikryl wrote:
I'm in a middle of rewrite of the assembly. Will contact you once that's done.


When your ready I would also be happy to help beta test the assembly it will streamline the entire process.

Many thanks

johnmichael.quinlan@googlemail.com
bebbe
[View user's profile]

Joined: 2012-02-15
Posts: 1
Location: Germany, Bavaria
Hi!

Could you send me the beta of the assembly as well?

Many thanks
bebbe
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
I have sent a new version of the assembly to all of you.
_________________
Martin Prikryl
lambo77
[View user's profile]

Joined: 2012-02-17
Posts: 1
Location: dublin Ireland
prikryl wrote:
I have sent a new version of the assembly to all of you.



would I be able to get a Copy of the dll too?
Guest




prikryl wrote:
I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?


Hi Martin,
can you send me the assembly as well?
My email is elwood.net [at] gmail.com
Thanks in advance.
Best Regards,
Elwood.
pi_guy
[View user's profile]

Joined: 2012-02-20
Posts: 1
Hi would it be possible to get a preview of the assembly? I'm doing dev for a file transfer heavy application and am try to assess which is the best way to go about this.

Thank you
Allen Brown
allen [at] qualica.com
andys
[View user's profile]

Joined: 2012-02-08
Posts: 3
New assembly implemented and appears to be working fine. Not doing complicated transfer, but have got it transfering zip files between servers and checking results.

Thanks
singhgauravk
[View user's profile]

Joined: 2012-02-23
Posts: 2
Hello, would it also be possible for me to get the DLL for testing purposes (email at singhgauravk At yahoo.com). Appreciate your help with this.
Thanks

Gaurav
singhgauravk
[View user's profile]

Joined: 2012-02-23
Posts: 2
prikryl wrote:
I have emailed you too.


Hey Martin,

Sorry to disturb you again, but I am stuck and would really appreciate if you could email me the files.
Thanks again!

Gaurav
pedonsito
[View user's profile]

Joined: 2012-02-24
Posts: 1
please, can you send me assembly by email.
fandres [at] gmail

Thanks you
techuser
[View user's profile]

Joined: 2012-02-27
Posts: 1
Location: United States
I would like to get the beta of the .NET DLL. I have been trying to use the SFTP method as a process within VB.NET http://winscp.net/forum/posting.php?mode=reply&t=10734, and XML logging appears to work great when the username, password, etc. are correct. However, if I change any of these so that it fails, the XML logging does not seem to work correctly (just stops), and all I can retrieve is an error code of the process that it did not complete, but not any additional information as to why it didn't complete.

It is my hope that the .NET DLL being developed will be able to correctly provide detailed logging information such as bad username, bad password, unable to reach server,etc should a transmission not work. Something that would provide direction as to why the transmission failed.
Priti

Guest


Can you please send me the .NET Assembly DLL as well???? Pleaseeeeeeeeeeeeeeeeeeee!!!! Smile

Thanks!!
sandhupretty@hotmail.com
marcibme
[View user's profile]

Joined: 2012-02-29
Posts: 1
prikryl wrote:
I have sent a new version of the assembly to all of you.


Can you send it to marcibme[at]gmail.com as well?
Thanks a lot!
akenato82

Guest


Hello, can I have WinSCP .NET assembly for try and test it!
Thanx a lot
akenato82

Guest


akenato82 wrote:
Hello, can I have WinSCP .NET assembly for try and test it!
Thanx a lot


My Email is nkmelil@gmail.com
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
WinSCP 5.0.6 beta, including the .NET assembly has been released already.
Priti

Guest


Hi Martin, I have a question about WINSCP.

It is working perfectly fine on my local machine with my asp.net website. I installed Winscp and .net assembly as per the instructions on the production server also. But everytime I run a simple code for, lets say creating a connection to the remote Ssh server, it doesnt make any connection and following is the standardOutput:

winscp> open userID/Password/Host info .....Searching for host... Connecting to host... Authenticating... The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is. The server's dss key fingerprint is: ssh-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit

Can you please tell me what I am missing here?
Thanks,
sandhupretty@hotmail.com
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
Priti, post the code and we can probably offer more input. Without more complete information assisting you is difficult.



Thanks,

j0se

Reporting Bug or Asking for Support
libraryWinSCP .NET Assembly and COM Library Overview
Priti

Guest


Hi Jose, Follwing is the code(It's simply checking if user is authorised to login into the remote Ssh Server), It is working perfectly fine on my local machine......but when I run it on the production server, it is not detecting the host key.

Protected Function UnixServer_UserLoginAuthorization() As Boolean

Dim SessionOpen As Boolean
Dim iALPS_SessionOptions As New WinSCP.SessionOptions()

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With

Try
Using iALPS_Session As New WinSCP.Session
iALPS_Session.Open(iALPS_SessionOptions)

SessionOpen = iALPS_Session.Opened
iALPS_Session.Dispose()
End Using

Catch ex As Exception
Throw ex
SessionOpen = False
End Try

Return SessionOpen

End Function

The problem:

winscp> open userID:Password@Host info .....Searching for host... Connecting to host... Authenticating... The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is. The server's dss key fingerprint is: ssh-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
You've probably already checked this but is the UnixSshHostKey available on the server as well? Is it coming from some sort of cache that is only available on your local machine?

Examples:
ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx

Also, is the dll the latest from the download? Mine has an Assembly/File version of 1.0.0.235.
Priti

Guest


Hey Jose, The Standard Output which I pasted in the previous post is from, when I run the website on the Production Server. And It does have the host key returned by the Ssh Server. (I checked it is the right Ssh Host Key for that server.)

After Installing WinSCP on the Production Server, when I connected to the remote Ssh Server manually through WINSCP.exe, It asked for the host key to be saved in some cache memory. I said YES!!! Why website is not recognising that key saved?

And the same steps done on my local machine running fine??

Thanks,
Priti
Priti

Guest


And yes I did install the latest Version Just yesterday Smile
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
Priti wrote:
And the same steps done on my local machine running fine??

There are quite a few variables at play here. For example: Is your local machine and server both the same OS and do you have the same rights on both machines?

Have you considered hard coding the key into the code and attempting the connection?
Priti

Guest


Ok Local Machine and Server are different OS. Local is Windows XP and Server is Windows Server 2003 Neutral

Rights wise, what kind of rights specifically in respect to get WINSCP run through my asp.net site?

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With


UnixSshHostKey is hard coded for right now. Where I set the value for UnixSshHostKey in webConfig in application Settings and on pageload UnixSshHostKey has its hard coded value.
Confused
j0se
[View user's profile]

Joined: 2012-01-24
Posts: 8
Location: Wrong Place - Wrong Time
Priti wrote:
Rights wise, what kind of rights specifically in respect to get WINSCP run through my asp.net site?

Not sure if you're just pulling it from the app settings. Just as a test try printing the results of the iALPS_SessionOptions.SshHostKey = UnixSshHostKey.ToString to a log or the web page with some sort of qualifier to make sure there isn't an issue.

Aside from that I'm not sure what to recommend.
Priti

Guest


Ok I will try that!!

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Priti wrote:
winscp> open userID/Password/Host info .....Searching for host... Connecting to host... Authenticating... The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is. The server's dss key fingerprint is: ssh-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit

Please post a full log file showing the problem. (set Session.LogPath to enable logging).

Do not mask out the hostkey in the log. It would be useless then. Note that hostkey is public information anyway.
_________________
Martin Prikryl
Priti

Guest


Hello martin, thanks for replying Smile

Following is the code and output.

Protected Function UnixServer_UserLoginAuthorization() As Boolean
Dim SessionOpen As Boolean

Dim iALPS_SessionOptions As New WinSCP.SessionOptions()

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With

Try
Using iALPS_Session As New WinSCP.Session
iALPS_Session.Open(iALPS_SessionOptions)
SessionOpen = iALPS_Session.Opened
iALPS_Session.Dispose()
End Using

Catch ex As Exception
Response.Write(ex)
SessionOpen = False
End Try

Return SessionOpen

End Function

The above function runs totally fine on my local machine, but gives the following output when I run it at Production Server. It waits for 3-4 minutes and then display the following:

System.TimeoutException: Timeout waiting for WinSCP to respond. at WinSCP.Session.CheckForTimeout() at WinSCP.Session.Open(SessionOptions sessionOptions) at _Default.UnixServer_UserLoginAuthorization() in D:\Pritpal\Test\Default.aspx.vb:line 154

Similarly if I run the following code on my loca Machine It runs fine with active connection to the remote server but not on the production Server. If there is some permission, Security or web.config/ Machine.config setting I need to change?

Dim UserOpenSessionString As String = "open " & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString
Dim SftpProcess As Process = New Process()
SftpProcess.StartInfo.FileName = "C:\Program Files\WinSCP\winscp.com"

SftpProcess.StartInfo.UseShellExecute = False
SftpProcess.StartInfo.RedirectStandardInput = True
SftpProcess.StartInfo.RedirectStandardOutput = True
SftpProcess.StartInfo.CreateNoWindow = True
SftpProcess.Start()

SftpProcess.StandardInput.WriteLine(UserOpenSessionString)
SftpProcess.StandardInput.WriteLine("exit")

SftpProcess.StandardInput.Close()

'Collect all output (not used in this example)
Dim output As String = SftpProcess.StandardOutput.ReadToEnd()

'Wait until WinSCP finishes
SftpProcess.WaitForExit()

This is the output when I run the above code on local machine. It runs fine.
"winscp> open UserID:Password@RemoteMachineName Searching for host... Connecting to host... Authenticating... Using username "UserID". Authenticating with pre-entered password. Authenticated. Starting the session... Reading remote directory... Session started. Active session: [1] UserID@RemoteMachineName winscp> exit "

The following is the output when I run this above sample code on the Production Server.

winscp> open UserID:Password@RemoteMachineName Searching for host... Connecting to host... Authenticating... The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is. The server's dss key fingerprint is: ssh-dss 2048 26:e3:61:cf:57:8a:72:22:28:4c:aa:e1:cf:e6:b4:89 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-dss 2048 26:e3:61:cf:57:8a:72:22:28:4c:aa:e1:cf:e6:b4:89. Authentication failed. winscp> exit
Priti

Guest


Hey Martin, As recommended in your documentation, I had to hard code the Host Key in my code.

So looks like its working fine now.

Thanks,
Priti Smile
Priti

Guest


The following worked for me....


"open sftp://" & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString & " -hostkey=" & """" & UnixSshHostKey.ToString & """"
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Priti wrote:
"open sftp://" & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString & " -hostkey=" & """" & UnixSshHostKey.ToString & """"

I'm confused. You've claimed that you use the .NET assembly.
_________________
Martin Prikryl
JustinK

Guest


I used the WinSCP .Net Assemble and wrote a VB script to transfer files.
However, I got a error message "Host key wasn't verified!".
My script is as following.
I have added the public key on remote server.
And the host key in the script is the finger print of the private key.
There is no problem if I use WinSCP GUI to connect to the remote server.
Could anyone help me to fix the issue?

Option Explicit

' Setup session options
Dim sessionOptions
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
With sessionOptions
.HostName = "test.com"
.UserName = "test"
.Password = "password"
.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
End With

Dim session
Set session = WScript.CreateObject("WinSCP.Session")

' Connect
session.Open sessionOptions

' Upload files
Dim transferOptions
Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions")
'transferOptions.TransferMode = TransferMode.Binary

Dim transferResult
Set transferResult = session.PutFiles("c:\data\mylogfile.txt", ".", False, transferOptions)

' Throw on any error
transferResult.Check

' Print results
Dim transfer
For Each transfer In transferResult.Transfers
WScript.Echo "Upload of " & transfer.FileName & " succeeded"
Next

' Disconnect, clean up
session.Dispose
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
JustinK wrote:
And the host key in the script is the finger print of the private key.

SessionOptions.SshHostKey is fingerprint of server's public key (host key).
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Please use .NET assembly / COM library forum for related questions.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License