question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InvalidOperationException from valid PathFigure definition

See original GitHub issue
  • .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.

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:

<Path Stroke="HotPink" StrokeThickness="1">
    <Path.Data>
        <PathGeometry>
            <PathFigure x:Name="StartFigure">
                <LineSegment Point="{Binding StartPoint, ElementName=StartFigure}" />
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>

PathFigureRepro.zip

(Stolen from MSDN Forums after experiencing a similar exception)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LyndonGingerichcommented, Sep 26, 2022

Here’s an MRE from the Behavior I was writing when I encountered this exception.

PathFigureRepro.zip

0reactions
LyndonGingerichcommented, Oct 13, 2022

(just in case, PathFigure has IsClosed for this purpose)

True. This is a mere MRE. If you want a more convincing use case, I’ll post my Behavior code.

I am guessing not the easiest one to fix 😃

Bummer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - System.InvalidOperationException: A specified Include ...
InvalidOperationException : A specified Include path is not valid ... on Id (in my example) in your table definition : I think (maybe...
Read more >
InvalidOperationException Class (System)
The application called an interface that was marshaled for a different thread. Windows Forms app, Cross-thread operation not valid: Control 'TextBox1' accessed ...
Read more >
Writing a custom shape for WPF | Damian Edwards
This returns the Geometry object that defines the shape of your shape. ... in turn define a PathFigure (in our case only one...
Read more >
Top WPF Interview Questions and Answers (2023)
XAML language definitions are resolved using the xmlns:x namespace. ... As shown below, it throws an InvalidOperationException: ...
Read more >
Media integration layer - US7511718B2
A number of shape-specific Geometry types are provided, as well as a generalized PathGeometry that allows for explicit definition of more complex shaped ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found