This project has moved and is read-only. For the latest updates, please go here.

Backup / Restore to WP7

Mar 28, 2011 at 2:17 AM

Having a bit of an issue restoring a DB into a WP7 application.
I create the DB in a silverlight application, flush it, run a backup and save that out to a file.
I include that file in my project as an embedded resource, on startup of my WP7 app I startup the DB, check if its empty, if it is I restore the DB from the file, shutdown the db, restore the types.dat
file.  Startup the DB, try and do a query...

Querying is where it all falls apart, I can query my unnested objects
Customer has no complex types and it is loaded just fine.
My Order class that has a 'reference' to a Customer does not load, says that "Value can not be null.\r\nParameter name: key"

If, after I create the DB I add a new Order with a new Customer, I can query it just fine.

I'm sure I'm missing a step in the restoration/backup, but what is the step?


Using the latest and greatest fresh off SVN, IsolatedStorage driver, however I was having all the same issues with the Nuget version.

Mar 28, 2011 at 2:23 PM

I need to update the documentation. The latest version encapsulates the entire database so there is no need to hack the types.dat. You should be able to eliminate the "restore types.dat" step. Instead, generate the backup, embed it, restore it and reactivate the engine. Let me know if this solves the issue you are having or if you still encounter issues after that change.


Mar 29, 2011 at 12:08 AM

Well that helped cleanup the code a bit, but same issue.

Here is what I see from the log, RedDGoRoute has a reference to a RedDGoStation

3/28/2011 7:04:47 PM::Sterling::Verbose::Resolved database path from RedDGoDatabase to Sterling/-2117543744/
3/28/2011 7:04:47 PM::Sterling::Verbose::Resolved table path from RedDGoDatabase.Entities.RedDGoRoute to Sterling/-2117543744/0/
3/28/2011 7:04:47 PM::Sterling::Verbose::Sterling is de-serializing type RedDGoDatabase.Entities.RedDGoRoute
3/28/2011 7:04:47 PM::Sterling::Verbose::[NOT NULL]
3/28/2011 7:04:47 PM::Sterling::Verbose::[NOT NULL]
3/28/2011 7:04:47 PM::Sterling::Verbose::[NOT NULL]
3/28/2011 7:04:47 PM::Sterling::Verbose::[NOT NULL]

Mar 29, 2011 at 12:09 AM

In my generation script I'm saving my stations, then creating my routes with something like route1.Station = station1, then save the route.

Apr 2, 2011 at 2:33 AM

Ok finally had time to debug into Sterling to find my issue, of course it was my fault. 

In my Generator project I was linking in my entity classes, so when my phone app tried to deserialize the entity, the type name had the wrong Assembly name.


All fixed now.

Apr 4, 2011 at 12:09 PM

Glad it worked out for you ... let me know if you hit any other bumps. I know the assembly qualified name has caused issues for some people, there is a post about modifying the code to create a "type interceptor" to resolve types that I am considering integrating into the next release that will give some more flexibility with versions.