title: XML deserialization error with root
body: <p>I am having a problem while deserializing an XML:</p>
  
  <pre><code>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: 
  </code></pre>
  
  <p>When going into the inner exception details the main error message is this:
  {"Root element is missing."}</p>
  
  <p>My xml file is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  
  &lt;entity name="ScheduleTaskEntity" schema="bclscheduler" namespace="http://www.bcl-gaming.com/data/1"&gt;
  &lt;columns&gt;
  &lt;column name="Id" type="identity" /&gt;
  &lt;column name="UID" type="UID" /&gt;
  &lt;column name="Timestamp" type="timestamp"/&gt;
  &lt;column name="DateCreated" type="datecreated"/&gt;
  &lt;column name="Enabled" type="bool" /&gt;
  &lt;column name="TypeFullname" type="string" size="500" /&gt;
  &lt;column name="PropertiesLOB" type="propertybag" /&gt;
  &lt;column name="DisplayName" type="string" size="64" /&gt;
  &lt;column name="LastDateExecuted" type="datetime" nullable="true" /&gt;
  &lt;column name="LastMessage" type="string" /&gt;
  &lt;column name="LastSessionUID" type="guid" nullable="true" /&gt;
  &lt;column name="CurrentState" type="string" /&gt;
  &lt;column name="LastDateStarted" type="datetime" nullable="true"/&gt;
  &lt;column name="SingleInstance" type="boolean" /&gt;
  &lt;column name="ExecuteCount" type="bigint" /&gt;
  &lt;column name="ErrorCount" type="bigint" /&gt;      
  &lt;/columns&gt;
  &lt;/entity&gt;
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>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();
  </code></pre>
  
  <p>Any ideas?</p>