XmlSerializer Workshop

The .NET Framework provides an exceptionally useful feature in the
System.Xml.Serialization namespace - the XmlSerializer. This class takes
classes that you have developed and turns them into an XML representation.
It can then turn an XML representation of your class back into a class
instance. Very useful.

When you first try to serialize a type the XmlSerializer creates some
C# code which reads and writes values to and from the type. It then compiles
this code into an in-memory assembly. Unfortunately, sometimes this doesn't
work and you either get a bunch of exceptions telling you why or a cryptic
"can't load xyzxyzab.dll" exception. Both of these error types are caused
by your type being incompatible with XmlSerializer. The second type of
error, though, doesn't tell you why it's incompatible.

How can XmlSerializer Workshop help?

This tool allows you to load an assembly and safely try to create an
XmlSerializer for any type in that assembly. If an XmlSerializer cannot
be created the software shows you why - including allowing you to view
the source code created by the serializer.

XSW is released under a BSD-style open-source license - hopefully it
will help others. The source shows a couple of interesting techniques
including using a separate AppDomain to host the main application so
that the application can delete temporary assemblies after running.
If you have improvements please do
send them back so
that I can merge them in and release them for others to use.

This tool was heavily inspired by the
Tool
that Chris Sells
released which helped me immensely when I was having difficulties with
XmlSerializer. Thanks Chris!