Debugging the XmlSerializer

13 May 2008 13:05

So we all love the XmlSerializer right! Probably a lot more than the DataContractSerializer, but then we have had more time to get used to it's ways.  Most of the time we don't need to care what's going on, but sometimes (and usually when we are forced into doing some custom serialization) it doesn't do exactly what we expected and after the allowable "couple of minutes" of trial and error (or is that just me) we need to step through the serialization code to see what's up.

First thing needed is to add diagnostics switches on XmlSerializer in the applications config file:

   1: <system.diagnostics>
   2:       <switches>
   3:          <add name="XmlSerialization.Compilation" value="1" />
   4:       </switches>
   5: </system.diagnostics>

Then compile and run the application in debug to the point immediately after the XmlSerializer in constructed for the type:

   1: XmlSerializer ser = new XmlSerializer(typeof(MyType));

The dynamic assembly and c# source is created in c:\documents and settings\[user]\local settings\temp under XP or c:\users\[user]\appdata\local under Vista - open the latest created *.cs file in your debug visual studio instance and off you go!



Powered by BlogEngine.NET 1.1.2.9

Calendar

<<  May 2013  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Search

Disclaimer

The opinions expressed in this blog are my own personal opinions and (for legal reasons) are not necessarily the views of anyone else (probably in the world) and particularly my employer!

Sign in

E-mail me Send mail

© Copyright 2013