XmlSerializer: could not load file or assembly XYZ
By Peter Bromberg
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.
Microsoft knows that there is an exception being thrown if the precompiled serialization
assembly can't be found and they deliberately made the decision to allow that
to happen since avoiding that exception would be too costly. "Too costly"
means here: "It would slow down your program if we did that".
One of the possible ways to get rid of this problem is check "Just my code"
option in Tools -> Options -> Debugging -> General options
If you need to break on all exceptions, then you can drill down into the Common Language
Runtime Exceptions node in Debug / Exceptions and check or uncheck the ones you
want.
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.
You can also use the SGEN tool to generate serialization assembly which can be placed next to the target assembly.
XmlSerializer: could not load file or assembly XYZ (2452 Views)