无法加载文件或程序集'diffiehellman [英] Could not load file or assembly 'diffiehellman

查看:116
本文介绍了无法加载文件或程序集'diffiehellman的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam创建c#应用程序将文件从本地上传到SFTP,但它无法连接到sftp并且它抛出异常



搜索完所有网站后,他们说安装DiffieHellman和Org.Mentalis.Security。



即使安装了这2个dll,我也会遇到同样的错误。



i给出了我的示例代码



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); // Throws Error here
             string LocalDirectory1 = LocalDirectory + "/" + FileName;
             string ftpDirectory = _ftpDirectory + "/" + FileName;
             oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory + "/" + FileName);
             oSftp.Close();





错误:



Session.connect:System.IO.FileLoadException:无法加载文件或程序集'DiffieHellman,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = 4ed5f4288b4076af'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)

文件名:'DiffieHellman,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = 4ed5f4288b4076af'

at Tamir.SharpSsh.jsch。在Tamir.SharpSsh.jsch.DHG1.init(会话会话,字节[] V_S,字节[] V_C,字节[] I_S,字节[] I_C)的jce.DH.getE()

br />
at Tamir.SharpSsh.jsch.Session.receive_kexinit(Buffer buf)

at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)



===预绑定状态信息===

日期:DisplayName = DiffieHellman,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = 4ed5f4288b4076af
(完全指定)

日志:Appbase = file:/// D:/ vinodh / Workout / SFTP_SharpSSH / SFTP_SharpSSH / bin / Debug /

日志:初始PrivatePath = NULL

调用程序集:Tamir.SharpSsh,Version = 1.1.1.13,Culture = neutral,PublicKeyToken = 4ed5f4288b4076af。

===

日志:此绑定在默认加载上下文中启动。

日志:使用a应用程序配置文件:D:\vinodh \ WORKout \SFTP_SharpSSH \SFTP_SharpSSH \bin \Debug \SFTP_SharpSSH.vshost.exe.Config

日志:使用主机配置文件:

日志:使用C:\ Windows \ Macrooft.NET \Framework\v4.0.30319 \ config \machine.config中的机器配置文件。

日志:政策后参考:DiffieHellman,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = 4ed5f4288b4076af

日志:尝试下载新的URL文件:/// D:/ vinodh / Workout / SFTP_SharpSSH / SFTP_SharpSSH /bin/Debug/DiffieHellman.DLL。

WRN:比较程序集名称导致不匹配:PUBLIC KEY TOKEN

错误:无法完成程序集的设置(hr = 0x80131040)。探测终止。



我尝试过:





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); // Throws Error here
                string LocalDirectory1 = LocalDirectory + "/" + FileName;
                string ftpDirectory = _ftpDirectory + "/" + FileName;
                oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory + "/" + FileName);
                oSftp.Close();

推荐答案

首先,您是否已将它们添加为项目的引用?如果已将它们添加为引用,是否确保已将它们设置为复制到输出目录? diffiehelman是否还有您需要复制的依赖项?它可能带有您需要在客户端上运行的运行时安装程序,以确保安装所有依赖项。
First of all, have you added them as references to your project? If you have added them as references, have you made sure that you have set them to be copied to the output directory? Does diffiehelman have any dependencies that you need to copy across as well? It might come with a runtime installer that you need to run on your clients to ensure that all the dependencies are installed.


错误消息的相关部分似乎是:

The relevant part of the error message would seem to be:
Quote:

WRN:比较程序集名称导致不匹配:PUBLIC KEY TOKEN

WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN



您下载的程序集与编译 Tamir.SharpSsh 的程序集不匹配。



如果找不到匹配的装配版本,则需要下载源 [ ^ ]并针对新版本重新编译DiffieHellman程序集。


The assembly you've downloaded doesn't match the assembly that Tamir.SharpSsh was compiled against.

If you can't find a matching version of the assembly, you'll need to download the source[^] and recompile it against the new version of the DiffieHellman assembly.


这篇关于无法加载文件或程序集'diffiehellman的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆