Solved

XmlSerializer(this.GetType());

Posted on 2013-06-12
3
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 36

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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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