Why did I get an error with my XmlSerializer?

前端 未结 5 833
粉色の甜心
粉色の甜心 2020-12-23 13:39

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.XmlS         


        
相关标签:
5条回答
  • 2020-12-23 14:19

    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

    0 讨论(0)
  • 2020-12-23 14:25

    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 :).

    0 讨论(0)
  • 2020-12-23 14:26

    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.

    0 讨论(0)
  • 2020-12-23 14:27

    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.

    0 讨论(0)
  • 2020-12-23 14:31

    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.
    0 讨论(0)
提交回复
热议问题