dotnet / dotnet/wpf

InvalidOperationException from valid PathFigure definition

Open
#7,110 10 comments 1 reaction 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 6.0.9
* Windows version: 10.0.19044 Build 19044
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
* Security issues and bugs should be reported privately, learn more via our [responsible disclosure guidelines](https://github.com/dotnet/wpf/blob/main/README.md#reporting-security-issues-and-security-bugs).



**Problem description:**

The program throws an exception rather than running.

**Actual behavior:**

```
System.Windows.Markup.XamlParseException: 'Set property 'System.Windows.Shapes.Path.Data' threw an exception.' Line number '14' and line position '19'. ---> System.InvalidOperationException: Current local value enumeration is outdated because one or more local values have been set since its creation.
at System.Windows.DependencyObject.InsertEntry(EffectiveValueEntry entry, UInt32 entryIndex)
at System.Windows.DependencyObject.SetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, Int32 targetIndex, PropertyMetadata metadata, Object value, BaseValueSourceInternal valueSource)
at System.Windows.UncommonField`1.SetValue(DependencyObject instance, T value)
at System.Windows.DependencyObject.UpdateSourceDependentLists(DependencyObject d, DependencyProperty dp, DependencySource[] sources, Expression expr, Boolean add)
at System.Windows.DependencyObject.ChangeExpressionSources(Expression expr, DependencyObject d, DependencyProperty dp, DependencySource[] newSources)
at System.Windows.Data.BindingExpressionBase.ChangeSources(WeakDependencySource[] newSources)
at MS.Internal.Data.ClrBindingWorker.ReplaceDependencySources()
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.AttachDataItem()
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.OnInheritanceContextChanged(Object sender, EventArgs e)
at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Windows.DependencyObject.OnInheritanceContextChanged(EventArgs args)
at System.Windows.Media.PathSegmentCollection.OnInheritanceContextChangedCore(EventArgs args)
at System.Windows.DependencyObject.OnInheritanceContextChanged(EventArgs args)
at System.Windows.Media.PathFigureCollection.OnInheritanceContextChangedCore(EventArgs args)
at System.Windows.DependencyObject.OnInheritanceContextChanged(EventArgs args)
at System.Windows.Freezable.AddInheritanceContext(DependencyObject context, DependencyProperty property)
at System.Windows.DependencyObject.ProvideSelfAsInheritanceContext(DependencyObject doValue, DependencyProperty dp)
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.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
--- End of inner exception stack trace ---
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at PathFigureRepro.MainWindow.InitializeComponent() in C:\Users\Lyndon.G\Desktop\PathFigureRepro\PathFigureRepro\MainWindow.xaml:line 1
at PathFigureRepro.MainWindow..ctor() in C:\Users\Lyndon.G\Desktop\PathFigureRepro\PathFigureRepro\MainWindow.xaml.cs:line 25
```

**Expected behavior:**

Program runs

**Minimal repro:**

```XAML







```

[PathFigureRepro.zip](https://github.com/dotnet/wpf/files/9636938/PathFigureRepro.zip)

(Stolen from [MSDN Forums](https://social.msdn.microsoft.com/forums/vstudio/en-US/9c4ba357-6341-4a58-b76d-3858f3717c0d/error-binding-pathdata-in-35-sp1?forum=wpf) after experiencing a similar exception)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.