I am using static a Resource Dictionary which is initialized the following way:
static ResourceDictionary resource = new ResourceDictionary()
{
Source = new Uri(
"pack://application:,,,/CommonResources;component/ApplicationData.xaml")
};
The code has been working perfectly for the last few months but in the last few days I've started experiencing the following problem:
Exception of type 'System.Xaml.XamlParseException' was thrown. at System.Windows.Baml2006.Baml2006Reader.ReadObject(KeyRecord record) at System.Windows.ResourceDictionary.CreateObject(KeyRecord key) at System.Windows.ResourceDictionary.RealizeDeferContent(Object key, Object& value, Boolean& canCache) at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache) at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
Aside from the above initialization, the data is read from the dictionary by accessing the needed item:
if (resource.Contains(key))
{
return resource[key];
}
The only modification to the code might be related to many thread accessing the dictionary at the same time. It is also important to mention that the same code sometimes works perfectly and sometimes throws the above exception (Very inconsistent).
I Would appreciate any insights regarding the exception itself or the problem in general.