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

Dumping ViewModel into state on tombstoning fails as ViewModelBase does not have public paramaterless constructor

Oct 20, 2010 at 10:23 AM


Thanks for this great project, I am using it in my WP7 app and my SL4 app. 

I have a problem - to handle tombstoning in my WP7 app I dump my whole viewmodel into the PhoneApplicationService state as per this blog post.

This fails as all my VMs inherit from ViewModelBase which does not have a public parameterless constructor defined and therefore cannot be serilizable. I know I can edit the source but I was just wondering if this is by design or if it could be changed in the future (I am not a serialization or MVVM guru!)

Oct 22, 2010 at 2:19 AM

Laurent posted a reply to this here.

Nov 14, 2010 at 8:38 PM
Edited Nov 14, 2010 at 8:40 PM

I just hit a different manifestation of this same issue in my normal Silverlight 4 app trying to save ViewModels to IsolatesStorage. It took me a while to realise the issue due to misleading error messages from SL. You can read more about it here (check my answer)

So the work-around is to download the ViewModelBase class and mark it as public... hopefully this can be considered in a future release. I have found the need to save my VM to disk on 2 different projects now - I am actually surprised no one has run into this issue before trying to persist ViewModels?