Exception when accessing Properties.Settings
-
Hi, my application runs some code in each interval. There the first line looks like
int sec = Settings.Default.Intervall;
in my case, the interval setting doesn't change and holds a value of 20, so every 20 secondsSettings.Default.Intervall;
is accessed. the problem is, that sometimes an exception occurs. this happens once a week or so. any idea what the point could be? FATAL 02.08.08 06:07:52 [ thrCounter]: Ein unbehandelter Fehler ist aufgetreten (sender: Name:Umm.exe There are no context policies. , exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at System.Configuration.SettingsPropertyValueCollection.get_Item(String name) at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName) at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName) at Umm.Properties.Settings.get_Intervall() in D:\VSSTools\Umm\Entwicklung\Properties\Settings.Designer.cs:line 31 at Umm.App.Controler.runIntervallWaiting() in D:\VSSTools\Umm\Entwicklung\App\Controler.cs:line 213 -
Hi, my application runs some code in each interval. There the first line looks like
int sec = Settings.Default.Intervall;
in my case, the interval setting doesn't change and holds a value of 20, so every 20 secondsSettings.Default.Intervall;
is accessed. the problem is, that sometimes an exception occurs. this happens once a week or so. any idea what the point could be? FATAL 02.08.08 06:07:52 [ thrCounter]: Ein unbehandelter Fehler ist aufgetreten (sender: Name:Umm.exe There are no context policies. , exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at System.Configuration.SettingsPropertyValueCollection.get_Item(String name) at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName) at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName) at Umm.Properties.Settings.get_Intervall() in D:\VSSTools\Umm\Entwicklung\Properties\Settings.Designer.cs:line 31 at Umm.App.Controler.runIntervallWaiting() in D:\VSSTools\Umm\Entwicklung\App\Controler.cs:line 213It looks like your SettingsPropertyValueCollection is getting corrupted, so that the values in the _Indices HashTable doesn't correspond to the size of the _Values ArrayList. The class itself should be pretty well tested, so there might be something in your code that is accessing some memory that it shouldn't. Typically that's only possible when using reflection, unsafe code blocks or calls to unmanaged code.
Despite everything, the person most likely to be fooling you next is yourself.