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

  • SEARCH
  • Home
  • 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 7402465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:45:01+00:00 2026-05-29T04:45:01+00:00

I am having a problem while deserializing an XML: System.InvalidOperationException was unhandled Message=There is

  • 0

I am having a problem while deserializing an XML:

System.InvalidOperationException was unhandled
  Message=There is an error in XML document (0, 0).
  Source=System.Xml
  StackTrace:
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
       at xsdToObject.Program.Main(String[] args) in D:\Old Documents\Projects\xsdToObject\xsdToObject\Program.cs:line 20
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Xml.XmlException
       Message=Root element is missing.
       Source=System.Xml
       LineNumber=0
       LinePosition=0
       SourceUri=""
       StackTrace:
            at System.Xml.XmlTextReaderImpl.Throw(Exception e)
            at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
            at System.Xml.XmlTextReaderImpl.Read()
            at System.Xml.XmlTextReader.Read()
            at System.Xml.XmlReader.MoveToContent()
            at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderentityColumnsColumnArray.Read3_ArrayOfEntityColumnsColumn()
       InnerException: 

When going into the inner exception details the main error message is this:
{“Root element is missing.”}

My xml file is as follows:

<?xml version="1.0" encoding="utf-8" ?>

<entity name="ScheduleTaskEntity" schema="bclscheduler" namespace="http://www.bcl-gaming.com/data/1">
<columns>
<column name="Id" type="identity" />
<column name="UID" type="UID" />
<column name="Timestamp" type="timestamp"/>
<column name="DateCreated" type="datecreated"/>
<column name="Enabled" type="bool" />
<column name="TypeFullname" type="string" size="500" />
<column name="PropertiesLOB" type="propertybag" />
<column name="DisplayName" type="string" size="64" />
<column name="LastDateExecuted" type="datetime" nullable="true" />
<column name="LastMessage" type="string" />
<column name="LastSessionUID" type="guid" nullable="true" />
<column name="CurrentState" type="string" />
<column name="LastDateStarted" type="datetime" nullable="true"/>
<column name="SingleInstance" type="boolean" />
<column name="ExecuteCount" type="bigint" />
<column name="ErrorCount" type="bigint" />      
</columns>
</entity>

My code is as follows:

entity e;

System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(entityColumnsColumn[]));
StreamReader reader = new StreamReader(@"D:\Old Documents\Projects\xsdToObject\xsdToObject\ScheduleTaskEntityTest.xml");
reader.ReadToEnd();
//it gives me the error here
e = (entity)x.Deserialize(reader);
reader.Close();

Any ideas?

  • 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-05-29T04:45:01+00:00Added an answer on May 29, 2026 at 4:45 am
    reader.ReadToEnd();
    //it gives me the error here
    e = (entity)x.Deserialize(reader);
    

    The problem is the reader.ReadToEnd() – after this there is nothing to read anymore and only then you are trying to deserialize – this must fail. Instead just use the StreamReader directly:

    using(StreamReader reader = new StreamReader(@"D:\Old Documents\Projects\xsdToObject\xsdToObject\ScheduleTaskEntityTest.xml"))
    {
        e = (entity)x.Deserialize(reader);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am facing a problem while apply xsl on xml. the xml is having
I am having a problem while parsing XML file,i used newsRSS parser as a
I have a flash file menu i am having problem while link it to
Hey dudes.i am having this problem while symlinking. I have successfully deployed a ruby
I've been having this problem for a while and it's driving me nuts. I'm
I'm having a problem with scala generics. While the first function I defined here
I am having a problem while calling overloaded C# function through jquery post method.
I'm having this problem while writing my own HashTable. It all works, but when
I am having a problem while doing some XSLT pre-processing in my java program.
i'm having a problem while encrypting some data in the file. i'm using simple

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.