for some reason everytime i restart the (in browser) silverlight application, isolated storage has no keys in it.
i have even tried this with a vanilla template with the code below. things i have checked:
always using the same port
on startup the application always created the entry in isolated storage (never persisted)
on shutdown, the keys are always present in isolated storage
Code:-
namespace SilverlightApplication1
{
public partial class MainPage : UserControl, INotifyPropertyChanged
{
private string _ChildCount;
public string ChildCount
{
get { return _ChildCount; }
set { NotifyPropertyChangedHelper.SetProperty(this, ref _ChildCount, value, "ChildCount", PropertyChanged); }
}
public MainPage()
{
InitializeComponent();
SaveData();
}
~MainPage()
{
CheckData();
}
private void SaveData()
{
if (!IsolatedStorageSettings.ApplicationSettings.Contains("childCheck"))
{
IsolatedStorageSettings.ApplicationSettings.Add("childCheck", Parent.Create(5, 5));
ChildCount = "Created Children(5)";
}
else
CheckData();
}
private void CheckData()
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("childCheck"))
{
if (((Parent)IsolatedStorageSettings.ApplicationSettings["childCheck"]).Children.Length == 5)
ChildCount = "Children Present";
else
ChildCount = "Parent present without children";
}
else
ChildCount = "Children not found";
}
public class Parent
{
public int Id { get; private set; }
public Child[] Children { get; private set; }
private Parent() { }
public static Parent Create(int id, int childCount)
{
var result = new Parent
{
Id = id,
Children = new Child[childCount]
};
for (int i = 0; i < result.Children.Length; i++)
result.Children[i] = Child.Create(i);
return result;
}
}
public class Child
{
public int Id { get; private set; }
private Child() { }
public static Child Create(int id)
{
return new Child { Id = id };
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
any help would be welcome.