dotnet / dotnet/wpf

System.Windows.ContextLayoutManager.UpdateLayout() throws KeyNotFoundException

Open
#7,542 13 comments 1 reaction 0 assignees View on GitHub
Needs minimal repro project
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

I get this exception quite often in my .NET 4.8 WPF app. The error is sent from clients automatically and I do not know how to reproduce it, or from what part of the code it originates.

I found a similar issue saying it had been fixed in 4.8:
[https://github.com/dotnet/wpf/issues/2152]

```
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at MS.Internal.WeakDictionary`2.get_Item(TKey key)
at System.Windows.Automation.Peers.ItemPeersStorage`1.get_Item(Object item)
at System.Windows.Automation.Peers.ItemsControlAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.ListViewAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
at System.Windows.Automation.Peers.ItemsControlAutomationPeer.UpdateChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.ContextLayoutManager.fireAutomationEvents()
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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
```

### Reproduction Steps

Don't know.

### Expected behavior

No exception

### Actual behavior

Program crashes?

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

.NET 4.8
Windows 10
x64

### Other information

_No response_

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.