为什么我的 XmlSerializer 出现错误?
我对工作应用程序进行了一些更改,并开始在这行代码中出现以下错误。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
发生这种情况的主要原因是我尝试序列化和反序列化的类型不匹配。 我正在序列化 ObservableCollection(组)并反序列化业务对象 - 继承 ObservableCollection(组)的组。
这也是问题的一部分......
来自 - http:// Social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/9f0c169f-c45e-4898-b2c4-f72c816d4b55/
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/
根据我发现的信息,与 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 :).
您似乎无法找到程序集 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.
您如何加载包含
Groups
类型的程序集? 我猜您使用Assembly.LoadFrom()
加载它,因为 XML 序列化程序使用相同的上下文(“LoadFrom”上下文)来尝试加载程序集以进行序列化。 如果是这样,您有几个选择:Assembly.Load()
而不是Assembly.LoadFrom()
。How did you load the assembly containing the
Groups
type? I'm guessing you loaded it withAssembly.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:Assembly.Load()
instead ofAssembly.LoadFrom()
.AppDomain.AssemblyResolve
to help the CLR find the assembly in question.对于我所选择的几个令人烦恼的 Visual Studio 项目,我更喜欢仅对 BindingFailure 和 System.IO.FileNotFoundException 禁用异常中断。
在 Visual Studio 中:对于“例外”对话框,Ctl+D、Ctl+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