iam creating c# application to upload file from local to SFTP, But it couldnt connect to sftp and it throws an exception
After searching all website, they said to install DiffieHellman and Org.Mentalis.Security.
Even after installing these 2 dll, iam getting same error.
i have given my sample code below
string _ftpURL = "jtend";
string _UserName = "kascope";
string _Password = "S@ssw0rd813";
int _Port = 22;
string _ftpDirectory = @"/";
string LocalDirectory = @"E:\To_Upload";
string FileName = "tests.xls";
Sftp oSftp = new Sftp(_ftpURL, _UserName, _Password);
oSftp.Connect(_Port);
string LocalDirectory1 = LocalDirectory + "/" + FileName;
string ftpDirectory = _ftpDirectory + "/" + FileName;
oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory + "/" + FileName);
oSftp.Close();
Error:
Session.connect: System.IO.FileLoadException: Could not load file or assembly 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=4ed5f4288b4076af' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=4ed5f4288b4076af'
at Tamir.SharpSsh.jsch.jce.DH.getE()
at Tamir.SharpSsh.jsch.DHG1.init(Session session, Byte[] V_S, Byte[] V_C, Byte[] I_S, Byte[] I_C)
at Tamir.SharpSsh.jsch.Session.receive_kexinit(Buffer buf)
at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)
=== Pre-bind state information ===
LOG: DisplayName = DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=4ed5f4288b4076af
(Fully-specified)
LOG: Appbase = file:///D:/vinodh/Workout/SFTP_SharpSSH/SFTP_SharpSSH/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Tamir.SharpSsh, Version=1.1.1.13, Culture=neutral, PublicKeyToken=4ed5f4288b4076af.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\vinodh\Workout\SFTP_SharpSSH\SFTP_SharpSSH\bin\Debug\SFTP_SharpSSH.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=4ed5f4288b4076af
LOG: Attempting download of new URL file:///D:/vinodh/Workout/SFTP_SharpSSH/SFTP_SharpSSH/bin/Debug/DiffieHellman.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
What I have tried:
<pre> string _ftpURL = "jtend";
string _UserName = "kascope";
string _Password = "S@ssw0rd813";
int _Port = 22;
string _ftpDirectory = @"/";
string LocalDirectory = @"E:\To_Upload";
string FileName = "tests.xls";
Sftp oSftp = new Sftp(_ftpURL, _UserName, _Password);
oSftp.Connect(_Port);
string LocalDirectory1 = LocalDirectory + "/" + FileName;
string ftpDirectory = _ftpDirectory + "/" + FileName;
oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory + "/" + FileName);
oSftp.Close();