David Crowell :: Occasional Thoughts

Some Dumb Tech Guy

  Home :: Contact :: Syndication  :: Login
  27 Posts :: 0 Articles :: 53 Comments

Archives

Post Categories

About Me

Archived Software

I spent time today trying to track down a bug in the project I'm working on.  I'm deserializing custom classes from XML stored as resources.  It works great, except when you introduce a tiny typo.  I kept getting this completely useless error:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll - There was an error reflecting type
 
Due to the way .NET handles XML serialization and deserialization  (creating a temporary assembly), there is no stack trace, and no clue of what went wrong.

Although this can be caused be any number of issues, in my case, one of the fields of my class is another class.  I had improperly marked it with [XmlAttribute] instead of [XmlElement]

It appears the only way to debug this is to comment out the fields of the class, and uncomment each one, until it breaks again.

<Sigh>... back to work...
posted on Tuesday, April 03, 2007 3:41 PM