The lack of Cassini support should be better handled or documented.

Aug 22, 2011 at 1:04 AM

At the very least this note in code should also be placed as part of the installation notes and also where the call hangs.

    // Note: On a development server (Cassini) you may get a serializationexception
    // with custom identities.  


For as much effort as went into this project, I don't understand why a workaround wasn't implemented.


System.InvalidOperationException was unhandled by user code
  Message=There is an error in XML document (0, 0).
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
       at MileageStats.Domain.Models.UserInfo.FromString(String userContextData) in C:\Users\SGM7\Documents\Silk\MileageStats\MileageStats.Domain\Models\UserInfo.cs:line 43
       at MileageStats.Web.Models.MileageStatsIdentity..ctor(FormsAuthenticationTicket ticket) in C:\Users\SGM7\Documents\Silk\MileageStats\MileageStats.Web\Models\MileageStatsIdentity.cs:line 46
       at MileageStats.Web.MvcApplication.PostAuthenticateRequestHandler(Object sender, EventArgs e) in C:\Users\SGM7\Documents\Silk\MileageStats\MileageStats.Web\Global.asax.cs:line 156
       at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  InnerException: System.Xml.XmlException
       Message=Root element is missing.
            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.XmlSerializationReaderUserInfo.Read3_UserInfo()



Aug 23, 2011 at 5:06 PM


I've created a work item in the issue tracker, so that the product team is aware of this.

Thanks for your feedback.

Guido Leandro Maliandi

Jan 10, 2012 at 6:08 PM

I downloaded and followed the steps as per the readme.mht.  When I try and run the application (Ctrl+F5) I get the exact error above...

In debug mode, I can see that the userContextData variable being passed into FromString is empty.  Now what?


Server Error in '/' Application.

Root element is missing.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Xml.XmlException: Root element is missing.

Source Error: 

Line 41:             using (var stream = new StringReader(userContextData))
Line 42:             {
Line 43:                 return serializer.Deserialize(stream) as UserInfo;
Line 44:             }
Line 45:         }

Source File: C:\Data\Downloads\Silk\MileageStats\MileageStats.Domain\Models\UserInfo.cs    Line: 43 

Stack Trace: 

[XmlException: Root element is missing.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +73
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +4115088
   System.Xml.XmlTextReaderImpl.Read() +145
   System.Xml.XmlTextReader.Read() +15
   System.Xml.XmlReader.MoveToContent() +70
   Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderUserInfo.Read3_UserInfo() +54

[InvalidOperationException: There is an error in XML document (0, 0).]
   System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +630
   System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader) +100
   MileageStats.Domain.Models.UserInfo.FromString(String userContextData) in C:\Data\Downloads\Silk\MileageStats\MileageStats.Domain\Models\UserInfo.cs:43
   MileageStats.Web.Models.MileageStatsIdentity..ctor(FormsAuthenticationTicket ticket) in C:\Data\Downloads\Silk\MileageStats\MileageStats.Web\Models\MileageStatsIdentity.cs:46
   MileageStats.Web.MvcApplication.PostAuthenticateRequestHandler(Object sender, EventArgs e) in C:\Data\Downloads\Silk\MileageStats\MileageStats.Web\Global.asax.cs:156
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Jan 11, 2012 at 7:56 PM


As mentioned in the code in MileageStatsIdentity.cs:

Note: On a development server (Cassini) you may get a serializationexception with custom identities.
See for more information.

This seems to be a known issue, and you might find possible workarounds for it in the aforementioned link.

I hope you find this helpful,

Agustin Adami

Jan 12, 2012 at 4:28 AM
Edited Jan 12, 2012 at 4:28 AM

Wrong forums.

Feb 1, 2012 at 7:51 PM


The issue was fixed in my case by running VS2010 as administrator.



Jul 28, 2012 at 9:49 AM

Same for me run as admin