什么可能导致 System.TypeLoadException? [英] What could be causing a System.TypeLoadException?

查看:29
本文介绍了什么可能导致 System.TypeLoadException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS2008 使用 C# 开发 Honeywell Dolphin 6100 的应用程序,Honeywell Dolphin 6100 是一款带有条形码扫描仪的移动计算机,使用类似操作系统的 Windows CE 5.0.

我想添加一个功能,可以将文件从本地设备发送到远程服务器.我发现图书馆Tamir.SharpSSH"这可以保证这一点.我在控制台应用程序和普通 Windows 窗体应用程序上测试了代码,它运行良好.但是当我尝试在 winCE 设备上使用相同的代码时,我收到了 TypeLoadException 并且出现了错误消息:

<前>无法从程序集Tamir.SharpSSH"加载类型Tamir.SharpSsh.SshTransferProtocolBase",版本=1.1.1.13,文化=中性,PublicKeyToken=null'.

我使用的代码如下:

SshTransferProtocolBase sshCp = new Scp(Tools.GlobalVarMeth.hostName, Tools.GlobalVarMeth.serverUserName);sshCp.Password = Tools.GlobalVarMeth.serverUserpassword;sshCp.Connect();string localFile = Tools.GlobalVarMeth.applicationPath + "/";+ 文件名 + .csv";string remoteFile = Tools.GlobalVarMeth.serverRemoteFilePath + "/";+ 文件名 + .csv";sshCp.Put(localFile, remoteFile);sshCp.Close();

有人对此有任何想法吗?我将不胜感激!!!

解决方案

它可以是任意数量的东西.可能的原因是:

  • 无法找到程序集
  • 找不到您的程序集所依赖的程序集
  • 找到了程序集,但类型不在其中
  • 该类型的静态构造函数抛出异常

最好的办法是使用 Fusion 日志查看器来帮助诊断.文档在这里:

http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx

(仅供参考Fusion"是设计程序集加载系统的团队的代号;有点不幸的是,代号最终出现在已发货产品的文件名中.这个东西应该被称为AssemblyBindingLogViewer.exe"或类似的东西.)

I'm developing, with VS2008 using C#, an application for Honeywell Dolphin 6100, a mobile computer with a barcode scanner that uses Windows CE 5.0 like OS.

I want to add a functionality that can send files from the local device to the distant server. I found the library "Tamir.SharpSSH" which can guarantee this. I tested the code on a console application and on normal windows forms application and it works perfectly. But when I tried to use the same code on the winCE device, I get a TypeLoadException and I have the error message:

Could not load type 'Tamir.SharpSsh.SshTransferProtocolBase' from assembly 'Tamir.SharpSSH,   
Version=1.1.1.13, Culture=neutral, PublicKeyToken=null'.

the code that I'm use is like below :

SshTransferProtocolBase sshCp = new Scp(Tools.GlobalVarMeth.hostName, Tools.GlobalVarMeth.serverUserName);
sshCp.Password = Tools.GlobalVarMeth.serverUserpassword;
sshCp.Connect();

string localFile = Tools.GlobalVarMeth.applicationPath + "/" + fileName + ".csv";
string remoteFile = Tools.GlobalVarMeth.serverRemoteFilePath + "/" + fileName + ".csv";

sshCp.Put(localFile, remoteFile);
   
sshCp.Close();

Any one have any idea on this ? I will be really grateful !!!

解决方案

It could be any number of things. Likely causes are:

  • The assembly cannot be found
  • An assembly that your assembly depends upon cannot be found
  • The assembly is found but the type isn't in it
  • The type's static constructor throws an exception

Your best bet is to use the Fusion log viewer to help diagnose it. Documentation is here:

http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx

(FYI "Fusion" was the code name of the team that designed the assembly loading system; it is somewhat unfortunate that the code name ended up in the file name of the shipped product. The thing should have been called "AssemblyBindingLogViewer.exe" or some such thing.)

这篇关于什么可能导致 System.TypeLoadException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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