为什么我的 XmlSerializer 出现错误?

发布于 2024-07-09 04:21:11 字数 2851 浏览 6 评论 0原文

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

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.

这是怎么回事?

I made a couple of changes to my working application and started getting the following error at this line of code.

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

And here is the error.

    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.

What's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

口干舌燥 2024-07-16 04:21:12

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

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

此异常是
XmlSerializer的正常运行。 它
预计将被抓住并且
在框架代码内部处理。
忽略它并继续。 如果它
在调试过程中打扰您,请设置
Visual Studio 调试器仅停止于
未处理的异常而不是全部
例外。

The main reason this was happening was because I had a mismatch in the types I was trying to Serialize and Deserialize. I was Serializing ObservableCollection (of Group) and deserializing a business object - Groups which inherited ObservableCollection (of Group).

And this was also part of the problem...
From - http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/9f0c169f-c45e-4898-b2c4-f72c816d4b55/

This exception is a part of the
XmlSerializer's normal operation. It
is expected and will be caught and
handled inside of the Framework code.
Just ignore it and continue. If it
bothers you during debugging, set the
Visual Studio debugger to only stop on
unhandled exceptions instead of all
exceptions.

旧伤还要旧人安 2024-07-16 04:21:12

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

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

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

According to information I found, BindingFailure exception associated with XmlSerializers sometimes does not indicate any error and should be just ignored, but you can sometimes see it i. e. in debug mode, when you have set VS options to show all thrown exceptions.

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

Btw. this is more or less one of the things mentioned in the first answer :).

暮色兮凉城 2024-07-16 04:21:12

您似乎无法找到程序集 FUSE.XmlSerializers。 检查程序集绑定日志查看器<的结果/a> (Fuslogvw.exe) 查看它正在寻找的位置(尽管上面提供的列表似乎相当完整)。

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

It appears that you cannot locate the assembly FUSE.XmlSerializers. Check the results of the Assembly Binding Log Viewer (Fuslogvw.exe) to see where it is looking (although the list presented above seems pretty full).

Try to locate where this assembly is stored on your computer and run NGen on it to see if it is failing to load for some reason. Make sure this DLL file is appearing in your Bin\Debug directory. Visual Studio doesn't seem to get the dependencies of dependencies, and so you have to make sure you have all the files you need yourself sometimes.

姐不稀罕 2024-07-16 04:21:12

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

  1. 使用 Assembly.Load() 而不是 Assembly.LoadFrom()
  2. 将处理程序附加到 AppDomain.AssemblyResolve 来帮助 CLR 找到有问题的程序集。

How did you load the assembly containing the Groups type? I'm guessing you loaded it with Assembly.LoadFrom() because the XML serializer is using the same context (the 'LoadFrom' context) to attempt to load assemblies for serialization. If so, you have a couple of options:

  1. Use Assembly.Load() instead of Assembly.LoadFrom().
  2. Attach a handler to AppDomain.AssemblyResolve to help the CLR find the assembly in question.
霓裳挽歌倾城醉 2024-07-16 04:21:12

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

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

1) 取消选中 < 下的 BindingFailure strong>托管调试助手

2) 取消选中公共语言运行时异常下的System.IO.FileNotFoundException。

啊,这样更好了:-)

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

For the select few Visual Studio projects I have where this is an annoyance, I prefer to disable break on exception for just the BindingFailure and the System.IO.FileNotFoundException.

In Visual Studio: Ctl+D, Ctl+E for the Exceptions dialog:

1) Uncheck BindingFailure under Managed Debugging Assistants

2) Uncheck System.IO.FileNotFoundException under Common Language Runtime Exceptions.

Ahhh that’s better :-)

...and I see 1/2 this answer was given by strager Nov 24 '10 at 10:12

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文