Several of our customers see this unhandled exception that we never experience ourselves or were able to reproduce.
Unhandled exception: The size of the state manager setting value has exceeded the limit (Excep_FromHResult 0x80073DC8)
What can cause this exception?
LocalSettings
do have some limits, see the Remarks section in ApplicationData.LocalSettings | localSettings property:
The name of each setting can be 255 characters in length at most. Each setting can be up to 8K bytes in size and each composite setting can be up to 64K bytes in size.
When the size of the setting is too large, it will raise this exception. Although there is no general size restriction on the total number of settings, it's better to store large data sets to files in isolated storage. So like @pstrjds said, you may need to verify the size of the settings in your app and if some of them could be large, you may try to store them in LocalFolder
.
Did some tests on Universal Windows application and discovered that each property value must not exceed 4095 bytes in size. So the following code will fix it:
/// <summary>
/// Application settings
/// Limit to 200*4095
/// </summary>
private const string SET_STR = "SETTINGS";
private const int CHUNK_SIZE = 4095;
static private ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
static private string AppSettings {
get {
string set = "";
for (int i = 0;i < 200;i++) {
string s = (string)localSettings.Values[SET_STR + i];
if (s != null) {
set += s;
} else {
break;
}
}
return set;
}
set {
for (int i = 0;i < 200;i++) {
localSettings.Values[SET_STR + i] = null;
}
for (int i = 0;i * CHUNK_SIZE < value.Length;i++) {
if (value.Length > i * CHUNK_SIZE) {
int len = (i + 1) * CHUNK_SIZE > value.Length ? value.Length % CHUNK_SIZE : CHUNK_SIZE;
localSettings.Values[SET_STR + i] = value.Substring(i * CHUNK_SIZE, len);
}
}
}
}
User contributions licensed under CC BY-SA 3.0