简体   繁体   English

无法加载文件或程序集System.IO.FileNotFoundException

[英]Could not load file or assembly System.IO.FileNotFoundException

The application i am developing is a simple remote chat application. 我正在开发的应用程序是一个简单的远程聊天应用程序。

I am experiencing this exception when i try to run my application. 当我尝试运行我的应用程序时,我遇到此异常。 I really do not understand when it talks about loading file or assembly. 当谈到加载文件或程序集时,我真的不明白。

"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Client, Version=1.0.0.0" “ System.Reflection.TargetInvocationException:调用的目标引发了异常。---> System.IO.FileNotFoundException:无法加载文件或程序集'Client,Version = 1.0.0.0”

try
{
   gt = (Greeting)Activator.GetObject(typeof(Greeting), "tcp://Localhost:7189/Greeting");
   handler = new MessageHandler(OnReceive);
   gt.Sender += handler;
}
catch(Exception ex)
{
   textBox2.Text = ex.ToString();
}

This exception is Thrown at this line 此行抛出此异常

gt.Sender += handler;

Below is my Greetings class. 以下是我的问候语课程。

[Serializable]
public delegate void MessageHandler(string mymsg);
public class Greeting:MarshalByRefObject
{
    public event MessageHandler Sender;

    public override object InitializeLifetimeService()
    {
        return null;
    }

    public Greeting()
    {
    }

    public void postGreeting(string msg)
    {
        if (Sender != null)
        {
            Sender(msg);
        }
    }
}

I assume the handler is created within your Client assembly? 我假设处理程序是在您的Client程序集中创建的? A reference to the handler is passed to your server assembly when you subscribe to the Greetings.Sender event. 订阅Greetings.Sender事件时,对该处理程序的引用将传递到您的服务器程序集。 As part of the deserialization on the server side it must resolve the handler type. 作为服务器端反序列化的一部分,它必须解析处理程序类型。 As it lives within the Client assembly this must be accessible to the server assembly. 由于它位于客户端程序集中,因此服务器程序集必须可以访问它。

Build all of your assemblies into a single shared debug or release folder and try again. 将所有程序集构建到一个共享的调试或发布文件夹中,然后重试。

使用Microsoft sysinternals进程监视器,配置该工具以监视应用程序的所有文件访问操作,然后您可以查看您的进程尝试访问的程序集。

the idea of using microsoft sysinternals process monitor worked perfectly for me. 使用Microsoft sysinternals进程监视器的想法对我来说非常理想。 i was able to see that it was looking for one of the dependencies in the wrong folder. 我能够看到它正在寻找错误文件夹中的依赖项之一。

If you experience Could not load file or assembly use the Assembly Binding Log Viewer (on disk called fuslogvw.exe and availbale from the .NET SDK) to find out exactly what your process is actually probing, either in the GAC or your application folder. 如果遇到Could not load file or assembly使用程序集绑定日志查看器 (在名为fuslogvw.exe磁盘上,以及.NET SDK中的availbale)在GAC或您的应用程序文件夹中准确找出您的进程实际上正在探查什么。

A typical logentry will hold info similar to this: 典型的登录条目将保存类似于以下内容的信息:

LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: graphicfailtest.resources, Version=0.0.0.0, Culture=en-US, PublicKeyToken=null
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft.NET/FrameworkSDK/Samples/Tutorials/resourcesandlocalization/graphic/cs/en-US/graphicfailtest.resources.DLL.

and you can then verify that it loads assemblies from a location you expect, inclusing if it is the correct version. 然后您可以验证它是否从期望的位置加载程序集,包括版本是否正确。

Probing from the msdn docs. 从msdn文档进行探测

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.IO.FileNotFoundException:无法加载文件或程序集 - System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: '无法加载文件或程序集 - System.IO.FileNotFoundException: 'Could not load file or assembly 奇怪的错误:System.IO.FileNotFoundException:无法加载文件或程序集 - Weird Error: System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: 无法加载文件或程序集 C# - System.IO.FileNotFoundException: Could not load file or assembly C# 无法加载程序集>> System.IO.FileNotFoundException:无法加载文件或程序集'System.Core, - Unable to Load assembly>>System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, System.IO.FileNotFoundException:无法加载文件或程序集“程序集名称”或其依赖项之一 - System.IO.FileNotFoundException: Could not load file or assembly 'name of assembly' or one of its dependencies 发布版本抛出“ System.IO.FileNotFoundException:无法加载文件或程序集”以查找XmlSerializers程序集 - Release build throws “System.IO.FileNotFoundException: Could not load file or assembly” looking for XmlSerializers assembly System.IO.FileNotFoundException:无法加载文件或程序集。 系统找不到文件SharpSvn.dll - System.IO.FileNotFoundException: Could not load file or assembly. The system cannot find the file SharpSvn.dll System.IO.FileNotFoundException:无法加载文件或程序集System.Xml.Linq - System.IO.FileNotFoundException: Could not load file or assembly System.Xml.Linq System.IO.FileNotFoundException:无法加载文件或程序集'System.Web.DataVisualization MEF MVC - System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.DataVisualization MEF MVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM