The XmlSerializer is a much maligned piece of software, but I have to tell you, it's the bomb. We use it a lot here at Corillian. Recently we had to debug a pretty funky problem where an enum was writing out to an XML file, but wasn't reading back in. We suspected it was a namespace thing, but the XmlSerializer is such a black box, a lot of people really have trouble dealing with it. It inspires a trial-and-error style, while I prefer to debug and step around myself.
Here's how to debug into a generated assembly from the XmlSerializer.
1. Given an application like:
public class Bar
public static void Main(string args)
XmlSerializer x = new XmlSerializer(typeof(Person));
Person p = new Person();
p.first = "Scott";
p.last = "Hanselman";
public class Person
public string first;
public string last;
2. Create a yourapplication.exe.config like this:
<?xml version="1.0" encoding="utf-8" ?>
<add name="XmlSerialization.Compilation" value="1" />
3. Compile and run and step up to the line where the XmlSerializer is constructed, and step over that line.
4. Go to c:\documents and settings\[username]\local settings\temp and look at the most recently created *.cs file. Open that file, it will have a name like asdasdfs.0.cs. Note that there are *.pdbs in that folder as well.
5. Set a breakpoint anywhere in that generated file.
6. Debug to taste (see screenshot below)