作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
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);
}
}
我得到:
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.
我不明白为什么。
最佳答案
我有同样的错误,可以通过添加 this NuGet package 来解决它来自 Mentalis到我的项目引用。
确保您拥有 NuGet package manager安装,首先。安装后,我这样做了:
右键单击 References > Manage nuget packages > 搜索 DiffieHellman > Install
这对我有用。
关于c# - Tamir.SharpSsh 无法加载文件或程序集 'DiffieHellman,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25382251/
我正在使用 Tmir.SharpSsh - SshExec 方法将一些命令发送到远程 SSH 服务器。 问题是这个方法或它创建的某个线程将输出发送到我的控制台窗口(“Sha1”)。 我想问问是否有人知
private void OVConnection() { try { //Create a new JSch instance JSch jsch = new
我正在使用 Tamir.SharpSsh 使用以下代码将文件上传到 ssh 服务器,但我收到 System.IO.IOException: Pipe closed.有什么线索吗? SshTransfe
这是我连接远程 SFTP 服务器并将文件发送到服务器的代码。 public static void SendDocument(string fileName, string host, string
我是一名优秀的程序员,十分优秀!