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

问题描述

我创建了一个我们在所有解决方案中使用的框架,这个框架有一个名为IfxEventWinClient的类,它有以下方法:

I created a framework which we use in all of our solutions, and this framework has a class called IfxEventWinClient which has the following method:

public string GetXml(bool includeBase)
{
    if (includeBase)
    {
        AssignBase();
    }
    else
    {
        _serializationHold = true;
    }

    XmlSerializer magic = new XmlSerializer(this.GetType());
    MemoryStream stream = new MemoryStream();
    magic.Serialize(stream, this);
    _serializationHold = false;
    return Encoding.UTF8.GetString(stream.ToArray(), 0, stream.ToArray().Length);
}

所有解决方案都使用.net 4.7并引用用于上述方法的程序集System.Xml。 在System.Xml参考的属性窗口中显示此路径:

All solutions are using .net 4.7 and reference the assembly System.Xml which is used for the method above.  In the properties window for the reference for System.Xml show this path:

C:\Program Files(x86)\ Reference Assemblies\Microsoft\Framework\.NETFramework \ v4.7 \System.Xml.dll

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Xml.dll

并且在运行框架解决方案时调用此方法时 - 它按预期运行。

and when this method is called while running the framework solution - it runs as expected.

然而,当这个框架被另一个解决方案(通过nuget包)使用并且调用相同的方法(在框架dll中)时,我得到以下异常,如下面的屏幕截图所示:

However, when this framework is consumed by another solution (via a nuget package) and this same method is called (in the framework dll) I get the following exception as shown in the screenshot below:

托管调试助手'BindingFailure' 发生了...
  Message =托管调试助手'BindingFailure':'具有显示名称'Ifx.EventWinClient.XmlSerializers'的程序集无法加载到ID为1的AppDomain的'LoadFrom'绑定上下文中。失败的原因是:System.IO。 FileNotFoundException:
无法加载文件或程序集"Ifx.EventWinClient.XmlSerializers,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null"或其依赖项之一。系统找不到指定的文件。'

Managed Debugging Assistant 'BindingFailure'  occurred
  Message=Managed Debugging Assistant 'BindingFailure' : 'The assembly with display name 'Ifx.EventWinClient.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Ifx.EventWinClient.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'

注意: 框架解决方案和使用该框架的解决方案都使用相同的System.Xml.dll位于

Note:  Both the framework solution and the solution consuming the framework are using the same System.Xml.dll located at

C:\Program Files(x86)\ Reference Assemblies\Microsoft \\ \\ Framework \ .NETFramework \v4.7 \System.Xml.dll

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Xml.dll

但异常  C:\ Windows \ Microsoft \\ Microsoft \\\\\\\\\\\\\\\\\\\\\\\ 0.30319 \System.Xml.dll。

but the exception C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll.

我不明白为什么我会收到这个例外。 有人可以对此有所了解吗?

I don't understand why i'm getting this exception.  Can someone please put some light on this?

谢谢。

推荐答案

感谢您在此发帖。

>> 在System.Xml参考的属性窗口中显示此路径:


C:\Program Files(x86)\\ \\ Reference Assemblies\Microsoft \Framework\.NETFramework\v4.7\System.Xml.dll

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Xml.dll


当这个方法在运行框架解决方案时调用d - 它按预期运行。

and when this method is called while running the framework solution - it runs as expected.

对于您的问题,我测试代码时没有自己定义的字段来重现错误。首先,我在4.7文件夹中测试dll。效果很好。

For your question, I test the code without the fields which defined by yourself to reproduce the error. First, I test the dll in 4.7 folder. It works well.

>> 但异常  C:\ Windows \ Microsoftoft.NET \ Framework \v4.0.30319 \ System .Xml.dll。

我从项目中删除了system.xml引用,并从NuGet包中添加了这个引用。它仍然运行良好。

I remove the system.xml reference from the project and add this reference from the NuGet Package. It still works well.

你能否提供一个简单的代码,可以重现错误让我测试?

最好的问候,

Wendy


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

10-30 02:44