WPF designer exception; "An item with the same key had already been added"
designer, exception, fonts, visual-studio-2010, wpf
Solution
(Solved)
Finally after hours of debugging found the solution.
I installed Visual Studio 2015 Preview and when I tried to open XAML file I got an error:
System.ArgumentException
An item with the same key has already been added
At System.ThrowHelper.ThrowArgumentException(ExceptionResource Resource) At System.Collections.Generic.Dictionary`2.Insert(...) At MS.Internal.FontFace.PhysicalFontFamily.ConvertDictionary(...)
That error didn't help much. So I created a local account and logged in with that new account. Then I got a message
There is a file or folder on you computer called C:\Program which would cause certain applications to not function correctly. Renaming it to C:\Program1 would solve this problem. Would you like to rename it now?
Once I deleted that file the XAML files appeared to be working.
So check in your C:\ if there is something different. Make sure you check all the hidden files also.
Problem
I am working on an app that uses WPF. In the designer, whenever I select a Label object while the Properties window is open and the Text section is expanded, within a second the designer disappears and gets replaced with a modeless error dialog: (X) An Unhandled Exception has occurred Click here to reload the designer Details: System.ArgumentException An item with the same key has already been added - At System.ThrowHelper.ThrowArgumentException(ExceptionResource Resource) - At System.Collections.Generic.Dictionary`2.Insert(...) - At MS.Internal.FontFace.PhysicalFontFamily.ConvertDictionary(...) I'm pretty sure the rest of it is irrelevant. I'm still developing the code; it's not even running. The exception is occurring in VS Designer's code. Obviously something is wrong with one of my fonts. How can I fix this? Edit We've already tried stopping the font-related services and clearing the font cache.