Solved

XmlSerializer(this.GetType());

Posted on 2013-06-12
3
221 Views
Last Modified: 2013-06-14
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'.
  Source=System.Xml
  StackTrace:
       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!
0
Comment
Question by:gswitz
3 Comments
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
ID: 39246232
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:
http://msdn.microsoft.com/en-us/library/182eeyhh%28VS.71%29.aspx
For further troubleshooting details:
http://msdn.microsoft.com/en-us/library/aa302290.aspx

If you need more help plese post your class declaration.
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 250 total points
ID: 39248453
Does your MyProjects.MyProject.SchemaObjectCollection object has a parameterless constructor?
0
 

Author Closing Comment

by:gswitz
ID: 39248855
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.

Thanks!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now