Encadeando erros com Application.LoadComponent (a chave já existe)
O MSDN diz que os membros estáticos públicos do System.Windows.Application são seguros para threads. Mas quando tento executar meu aplicativo com vários threads, recebo a seguinte exceção:
ArgumentException: An entry with the same key already exists.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
at System.IO.Packaging.Package.AddIfNoPrefixCollisionDetected(ValidatedPartUri partUri,
PackagePart part)
at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
at System.IO.Packaging.Package.GetPart(Uri partUri)
at System.Windows.Application.GetResourceOrContentPart(Uri uri)
at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean
bSkipJournaledProperties)
at System.Windows.Application.LoadComponent(Uri resourceLocator)
A exceção ocorre na seguinte chamada:
genericResources = (ResourceDictionary)Application.LoadComponent(new Uri("/Themes/Generic.xaml", UriKind.Relative));
O aplicativo funciona bem em um único segmento e até em dois ou três. Quando me levanto depois das 5, sempre recebo o erro. Estou fazendo algo errado? Oque posso fazer para consertar isso?