I've shot myself in the foot...

I've been cleaning up a project and I've made a few changes...

I'm trying to run a test and I call...

XmlSerializer Serializer = new XmlSerializer(this.GetType());

and I get...
System.InvalidOperationException was unhandled
  Message=There was an error reflecting type 'MyProjects.MyProject.SchemaObjectCollection'.
       at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

In an effort to make the problem resolve, I replaced the code in SchemaObjectCollection with the version before I created this problem. I've reverted several other files as well and I'm I bit stuck.

I'm probably giving insufficient information for help, but I thought I'd ask.

Thanks in advance for trying!
Who is Participating?
jorge_torizConnect With a Mentor Research & Development ManagerCommented:
Does your MyProjects.MyProject.SchemaObjectCollection object has a parameterless constructor?
Miguel OzConnect With a Mentor Software EngineerCommented:
Please post this.GetType() return value.

Then check that your class (defined in this value) is serializable (or has public properties) and have a parameterless constructor:
For further troubleshooting details:

If you need more help plese post your class declaration.
gswitzAuthor Commented:
Thanks folks. I ran after the wrong class because I hadn't checked the inner exception. Once I was on to the right class the fix was easy.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.