private void OVConnection()
{
try {
//Create a new JSch instance
JSch jsch = new JSch();
this.Dispatcher.BeginInvoke(new Action<Status>(DisplayStatus), Status.Connecting);
//Create a new SSH session
string host = "url"; //url
string user = "***"; //ssh username
string pass = "*******"; //ssh password
int sshPort = 22; //ssh port
int rPort = 3306;
int lPort = 3306;
int port = Convert.ToInt32(sshPort);
session = jsch.getSession(user, host, port);
session.setHost(host);
session.setPassword(pass);
UserInfo ui = new MyUserInfo();
session.setUserInfo(ui);
session.connect();
//Set port forwarding on the opened session
session.setPortForwardingL(lPort, "localhost", rPort);
if (session.isConnected()) {
MyDatabase();
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
this.Dispatcher.BeginInvoke(new Action<Status>(DisplayStatus), Status.NotConnected);
}
}
I get:
Session.connect: System.IO.FileNotFoundException: Could not load file or assembly 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
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=null
(Fully-specified)
LOG: Appbase = file:///C:/Development/2013/OV Projects/OmniView Documents Upload/Documents Upload/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Tamir.SharpSSH, Version=1.1.1.13, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\2013\OV Projects\OmniView Documents Upload\Documents Upload\bin\Debug\Documents Upload.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: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Development/2013/OV Projects/OmniView Documents Upload/Documents Upload/bin/Debug/DiffieHellman.DLL.
LOG: Attempting download of new URL file:///C:/Development/2013/OV Projects/OmniView Documents Upload/Documents Upload/bin/Debug/DiffieHellman/DiffieHellman.DLL.
LOG: Attempting download of new URL file:///C:/Development/2013/OV Projects/OmniView Documents Upload/Documents Upload/bin/Debug/DiffieHellman.EXE.
LOG: Attempting download of new URL file:///C:/Development/2013/OV Projects/OmniView Documents Upload/Documents Upload/bin/Debug/DiffieHellman/DiffieHellman.EXE.
I can not figure out why.
I had the same error and was able to resolve it by adding this NuGet package from Mentalis to my project references.
Make sure you have the NuGet package manager installed, first. After installing it, I did this:
Right-click References > Manage nuget packages > search for DiffieHellman > Install
This worked for me.
I got same error but when i add dll DiffieHellman.dll and Org.Mentalis.Security.dll then it is working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With