Reputation: 4268
I am having problems getting my app to restore/load from start after tombstoning.
It fails at the following line:
ServerCollection collection = AppSettings.GetSetting(AppResources.settings_servercollection) as ServerCollection;
This line is in a function that is called inside Launching and Activated.
The AppSettings class is this class Here:, but I modified it to use a object
instead of a <T>.
The debugger does not seem to enter the AppSettings function. It also displays the string i'm expecting to key on (AppResources.settings_servercollection
), so I do not think that is the problem either.
Lastly, no exceptions are thrown. I have the entire section in a try, and breakpoints inside UnhandledException
and NavigationFailed
of the application, but I never seem to arrive at any of them.
Has anyone else experienced this before, or know what the cause might be?
Edit: Just wanted to point out that of course the app works after Cleaning/Rebuilding/Reinstalling etc. Edit: I've been able to isolate it to this:
IsolatedStorageSettings Settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
I found that out by placing it in each the Get/Set functions of AppSettings, and seeing it die directly on that line after entering the function. That said, Any ideas?
Upvotes: 2
Views: 187
Reputation: 4268
The serialization turned out to be working Okay. The real problem was that I had some infinite recursion going on in a property that I was saving.
public Dictionary<string, object> Dictionary
{
get
{
if (_dictionary == null)
_dictionary = new Dictionary<string, object>();
return _dictionary;
}
set
{
Dictionary = value;
}
}
As you can probably see, that was not going to end well. Too bad there wasn't a "StackOverflowException" or anything like there is in the console C# applications i've written before.
Anyway, thanks for the help.. Hope anyone else who has this problem may find this helpful.
Upvotes: 1
Reputation: 66882
I've seen problems with apps where IsolatedStorage is in an invalid state
I am guessing that this is the problem with your app
private static IsolatedStorageSettings Settings
To try to fix the problem:
Upvotes: 2
Reputation: 65564
I suspect a problem with serialising (and deserializing) your ServerCollection
object.
Internally, objects passed to IsolatedStorageSettings
are serialized as XML (using DataContractSerializer
- which is probably part of the performance hit of using IsolatedStorageSettings
). If your object can't be deserialized correctly you could see this problem.
As an alternative I'd recommend handling the [de]serialization yourself and then storing the serialized version in IsolatedStorageSettings
.
Upvotes: 1