Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF designer exception; "An item with the same key had already been added"

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.

like image 454
AnotherParker Avatar asked Feb 18 '23 11:02

AnotherParker


1 Answers

(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.

like image 50
DV9 Avatar answered Feb 20 '23 10:02

DV9