42

我对我的工作应用程序进行了一些更改,并在这行代码中开始出现以下错误。

Dim Deserializer As New Serialization.XmlSerializer(GetType(Groups))

这是错误。

    BindingFailure was detected
    Message: The assembly with display name 'FUSE.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 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'

    Message: The assembly with display name 'FUSE.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 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'

=== Pre-bind state information ===
LOG: User = DOUG-VM\Doug
LOG: DisplayName = FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL
 (Fully-specified)
LOG: Appbase = file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Laptop\Core Data\Data\Programming\Windows\DotNet\Work Projects\NOP\Official Apps\FUSE WPF\Fuse\bin\Debug\FUSE.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\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:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.EXE.

这是怎么回事?

4

5 回答 5

68

发生这种情况的主要原因是我尝试序列化和反序列化的类型不匹配。我正在序列化 ObservableCollection (组)并反序列化一个业务对象 - 继承 ObservableCollection (组)的组。

这也是问题的一部分......来自 - http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/9f0c169f-c45e-4898-b2c4-f72c816d4b55/

此异常是 XmlSerializer 正常操作的一部分。它是预期的,并将在框架代码中被捕获和处理。忽略它并继续。如果它在调试期间困扰您,请将 Visual Studio 调试器设置为仅在未处理的异常而不是所有异常上停止。

于 2008-11-18T00:11:58.830 回答
8

根据我发现的信息,与 XmlSerializers 关联的 BindingFailure 异常有时并不表示任何错误,应该被忽略,但有时您可以在调试模式下看到它,当您设置 VS 选项以显示所有抛出的异常时。

来源: https ://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=88566&wa=wsignin1.0

顺便提一句。这或多或少是第一个答案中提到的事情之一:)。

于 2009-12-15T23:27:20.667 回答
1

您似乎无法找到程序集 FUSE.XmlSerializers。检查程序集绑定日志查看器(Fuslogvw.exe) 的结果以查看它的位置(尽管上面显示的列表似乎很完整)。

尝试找到此程序集在您的计算机上的存储位置并在其上运行NGen以查看它是否由于某种原因无法加载。确保此 DLL 文件出现在您的Bin\Debug目录中。Visual Studio 似乎无法获取依赖项的依赖关系,因此有时您必须确保自己拥有所需的所有文件。

于 2008-11-17T03:38:56.510 回答
0

您是如何加载包含该Groups类型的程序集的?我猜你加载它是Assembly.LoadFrom()因为 XML 序列化程序使用相同的上下文(“LoadFrom”上下文)来尝试加载程序集以进行序列化。如果是这样,您有几个选择:

  1. 使用Assembly.Load()而不是Assembly.LoadFrom().
  2. 附加一个处理程序AppDomain.AssemblyResolve以帮助 CLR 找到有问题的程序集。
于 2008-11-17T10:14:37.507 回答
0

对于我所拥有的少数几个令人烦恼的 Visual Studio 项目,我更喜欢仅为BindingFailureSystem.IO.FileNotFoundException禁用异常中断。

在 Visual Studio 中:Ctl+ DCtl+E用于“例外”对话框:

1) 取消勾选Managed Debugging Assistants下的 BindingFailure

2) 取消选中Common Language Runtime Exceptions下的 System.IO.FileNotFoundException 。

啊,那更好:-)

...我看到 1/2 这个答案是由 strager 2010 年 11 月 24 日 10:12 给出的

于 2014-06-21T01:15:50.177 回答