Error while opening database

May 31, 2010 at 10:00 AM
Edited May 31, 2010 at 11:33 AM


First of all I want to say great work!! it's complete and really easy to use.

While trying I had an issue, I might be missing something for sure, hope you can help me out.

The error is: - ex {"Cannot open database. See InnerException for details"} System.Exception {SilverlightPhoneDatabase.Exceptions.OpenException}

InnerException:  _message "There is an error in XML document (3, 4)." string

So I started debugging:  the error happens while deserializing   on this line:   ITable table = (ITable)serializer.Deserialize(stringReader);

in the function "LoadTable"; so I checked out the xml:  

"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfStudent xmlns:xsi=\"\" xmlns:xsd=\"\">\r\n <Student>\r\n  <FirstName>rodrigue</FirstName>\r\n <LastName>hajjar</LastName>\r\n    <Id>1</Id>\r\n  </Student>\r\n</ArrayOfStudent>"

the xml  seems fine to me: 



Here's my code:


Database db = Database.CreateDatabase("WPDemoPersistent");
                db.Table<Student>().Add(new Student("rodrigue", "hajjar"));

private void LoadStudents()
                Database db = Database.OpenDatabase("WPDemoPersistent");
                this.DataContext =  db.Table<Student>().ToList();
            catch (Exception ex)

Hope I was clear enough about my issue.
PS: I tried the sample project and everything works fine while running the tests.
Thanks in advance.


May 31, 2010 at 1:39 PM

Morning, Rodrigue,

Nothing really jumps at me right off the bat.  if you want to post your more code, I could take a closer look.  The issue seems to be with a student class, if you want to include that class in your post that would be helpfull as well.



May 31, 2010 at 1:42 PM

Thanks for your fast reply!

Here's my student class (nothing complicated): 

  public class Student
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public Student(string firstname, string lastname)
            FirstName = firstname;
            LastName = lastname;          

May 31, 2010 at 10:56 PM

Looks like XML you posted has ID column/property in it.  Could you do one more clean test with this student class?

Jun 1, 2010 at 7:46 AM

Yep sorry i posted the new class.

So I deleted the database and re-created one and the error still is the same at the same point when opening the database.

Here's the XML stream: 

"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfStudent xmlns:xsi=\"\" xmlns:xsd=\"\">\r\n  <Student>\r\n    <FirstName>rodrigue</FirstName>\r\n    <LastName>hajjar</LastName>\r\n  </Student>\r\n</ArrayOfStudent>" 

this is wierd :s 

Jun 6, 2010 at 2:03 PM

I cannot replicate the issue.  Can you emil me entire project?  My email is


Jun 9, 2010 at 1:57 AM

The issue was that you do not have a public parameter less constructor in your student class.  This break serialization.  This will not actually work in any Silverlight application, not just phone.

Jun 9, 2010 at 11:42 AM

That worked out! thanks for the support again..