Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:33:24+00:00 2026-06-13T08:33:24+00:00

I am having problems with deserializeation for an XML element, I am assuming it

  • 0

I am having problems with deserializeation for an XML element, I am assuming it is something to do with the namespace in the XML element not being found by the deserializer.

The data is coming form an outside source, which I cannot modify as a string and I am using C# 4.0.

Any help, gratefully appreciated.

string xml = "<boolean xmlns=\"http://schemas.microsoft.com/2003/10/serialization/\">false</boolean>";

var xSerializer = new XmlSerializer(typeof(bool));
using (var sr = new StringReader(xml)) 
using (var xr = XmlReader.Create(sr))
{
    var y = xSerializer.Deserialize(xr);
}

Error:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=There is an error in XML document (1, 2).
  Source=System.Xml
  StackTrace:
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
            ...
            ...
            ...
  InnerException: System.InvalidOperationException
       HResult=-2146233079
       Message=<boolean xmlns='http://schemas.microsoft.com/2003/10/serialization/'> was not expected.
       Source=System.Xml
       StackTrace:
            at System.Xml.Serialization.XmlSerializationPrimitiveReader.Read_boolean()
            at System.Xml.Serialization.XmlSerializer.DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
            at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       InnerException: 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:33:25+00:00Added an answer on June 13, 2026 at 8:33 am

    It will work if you create your serializer as below

    var xSerializer = new XmlSerializer(typeof(bool),null, null, 
                             new XmlRootAttribute("boolean"), 
                             "http://schemas.microsoft.com/2003/10/serialization/");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems binding on a form with multiple models being submitted. I have
Im Having Problems Figuring Out Why I am Receiving an Object reference not set
im having problems with formatting for a UITextView. my app pulls in XML, saves
Having problems getting the different arrays content from geocoder results. item.formatted_address works but not
Having problems getting the right data out of this multidimensional(?) array that I retrieve
Im having problems accessing a proprties collection attribute name for my pages element. Pages
Im having problems building a query with the linq to sql data query expression
I having problems with my 3 tier architecture. It seems that I could not
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.