I recently attempted to use the XmlSerializer on a class I had written, and found that I was continually being given an error (and not a pretty one at that). After hunting down resources all over the net, I was still stuck! I tried making similar classes (structurally) and they worked perfectly, but when my actual class was used, it gave the following error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: File or assembly name _gqi8w9n.dll, or one of its dependencies, was not found.
Obviously the dll name changed each time it was executed. I didn't really pay too much attention to the methods within the class, as they supposedly have no effect on serialization. Serialization is just a representation of the state of an object at the time of serialization, so a method should not affect it, right? Wrong!
I figured out that it was the operator overloading methods that were causing the problem, and after removing them everything worked perfectly! I'm looking into why the XmlSerializer has this limitation. To my mind, it is a limitation that should be done away with. I haven't managed to find anyone else that has written anything about this (including searches on MSDN, Google, DotNet247, SADev, and the like).
If anyone has come across this before or knows why it acts in such a way, please give some insight! You can check out this post on SADeveloper for more info.