locked
WPF VB.Net Unhandled Exception - Changing Font Family Of Any Control RRS feed

  • Question

  • I get the following error when attempting to use the designer to change the font family of any control in vb.net 2010(wpf). In fact, if I even move my mouse pointer over the property listed in the designer, I get this(see below), and have to reload my form in order to be able to visually edit the control again. This error always happens, regardless of what code my project contains.

    I am still learning wpf, is there something I am missing, or is this a configuration error, and how can it be fixed?

    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(TKey key, TValue value, Boolean add)
       at MS.Internal.FontFace.PhysicalFontFamily.ConvertDictionary(IDictionary`2 dictionary)
       at MS.Internal.FontFace.PhysicalFontFamily.MS.Internal.FontFace.IFontFamily.get_Names()
       at System.Windows.Media.FontFamily.get_FamilyNames()
       at MS.Internal.Services.WPFFontPlatformService.GetFontFamilyName(FontFamily fontFamily)
       at MS.Internal.Services.WPFFontPlatformService.GetSupportedFamilyNames()
       at MS.Internal.Designer.PropertyEditing.Editors.FontEditor.FontList.Refresh(EditingContext context)
       at MS.Internal.Designer.PropertyEditing.Editors.FontEditor.FontList.GetEnumerator()
       at MS.Internal.Data.EnumerableCollectionView.LoadSnapshotCore(IEnumerable source)
       at MS.Internal.Data.EnumerableCollectionView..ctor(IEnumerable source)
       at MS.Internal.Data.ViewManager.GetViewRecord(Object collection, CollectionViewSource cvs, Type collectionViewType, Boolean createView, Func`2 GetSourceItem)
       at MS.Internal.Data.DataBindEngine.GetViewRecord(Object collection, CollectionViewSource key, Type collectionViewType, Boolean createView, Func`2 GetSourceItem)
       at System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object source, Boolean createView, Func`2 GetSourceItem)
       at System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object source, DependencyObject d, Func`2 GetSourceItem)
       at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value, Func`2 GetSourceItem)
       at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
       at System.Windows.StyleHelper.InvalidateDependents(Style ownerStyle, FrameworkTemplate frameworkTemplate, DependencyObject container, DependencyProperty dp, FrugalStructList`1& dependents, Boolean invalidateOnlyContainer)
       at System.Windows.StyleHelper.OnTriggerSourcePropertyInvalidated(Style ownerStyle, FrameworkTemplate frameworkTemplate, DependencyObject container, DependencyProperty dp, DependencyPropertyChangedEventArgs changedArgs, Boolean invalidateOnlyContainer, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalMap& propertyTriggersWithActions, Int32 sourceChildIndex)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at MS.Internal.Designer.PropertyEditing.Automation.AutomatedChoiceEditor.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at MS.Internal.Designer.PropertyEditing.FromExpression.Framework.ValueEditors.ChoiceEditor.OnApplyTemplate()
       at System.Windows.FrameworkElement.ApplyTemplate()
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)


    If you want something you've never had, you need to do something you've never done. If you believe something to be true, then one day you will be called upon to demonstrate that truth.


    • Edited by Paul Ishak Wednesday, February 8, 2012 4:30 PM
    Wednesday, February 8, 2012 4:19 PM

Answers

  • I have seen similar posts in these forums, same error, lots of reasons.

    There is even an MS Connect ticket regarding it : http://connect.microsoft.com/VisualStudio/feedback/details/568541/wpf-an-item-with-the-same-key-has-already-been-added-system-argumentexception

    Of course it does not affect most people, so it must be specific to your machine.

    1) Try reinstalling VS AND  .Net

    2) Try installing on another machine

    3) Reinstall Windows, do all updates, install latest .Net, install VS

    If you search for this error you will find pages and pages of people with it and various suggestions/fixes.

    That is the simple answer to your actual question.

    Sorry I can't suggest a magic bullet that will fix it. Give it a day or so, and maybe someone else on these forums may know better...

    Regards,
    Pedro


    If you find my post helpful, please remember to "Mark As Answer" and/or "Vote as Helpful"

    • Marked as answer by Paul Ishak Wednesday, February 8, 2012 5:11 PM
    Wednesday, February 8, 2012 4:44 PM

All replies

  • I have seen similar posts in these forums, same error, lots of reasons.

    There is even an MS Connect ticket regarding it : http://connect.microsoft.com/VisualStudio/feedback/details/568541/wpf-an-item-with-the-same-key-has-already-been-added-system-argumentexception

    Of course it does not affect most people, so it must be specific to your machine.

    1) Try reinstalling VS AND  .Net

    2) Try installing on another machine

    3) Reinstall Windows, do all updates, install latest .Net, install VS

    If you search for this error you will find pages and pages of people with it and various suggestions/fixes.

    That is the simple answer to your actual question.

    Sorry I can't suggest a magic bullet that will fix it. Give it a day or so, and maybe someone else on these forums may know better...

    Regards,
    Pedro


    If you find my post helpful, please remember to "Mark As Answer" and/or "Vote as Helpful"

    • Marked as answer by Paul Ishak Wednesday, February 8, 2012 5:11 PM
    Wednesday, February 8, 2012 4:44 PM
  • ok, thank you, this confirms that I am not going insane. I will change the font programatically.

    If you want something you've never had, you need to do something you've never done. If you believe something to be true, then one day you will be called upon to demonstrate that truth.

    Wednesday, February 8, 2012 5:09 PM