You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
MessageHandlers not called anymore by WeakReferenceMessenger after UnregisterAll #4081
The attached message handlers of a WeakReferenceMessenger do not get called anymore correctly for all registered objects after unregistering one of them.
There seems to be an issue with the enumerator of the ConditionalWeakTable. The linked list nodes are not iterated correctly when a key gets removed while enumerating. In this case the "Next"-property of the node is set to null and the while loop stops immediately (without checking the remaining nodes).
Steps to Reproduce
Register two recipients to a WeakReferenceMessenger.
Call UnregisterAll for the second recipient
Handlers for the first recipient will not be called by Send 💥
For more details please see the following failing unit test:
Oh, good catch @steinhilber, thanks!
I had missed the fact that removing a LinkedListNode<T> also did side-effect on the node and cleared it 😄
@michael-hawker Just to add some more context here, this bug only affects the polyfill for ConditionalWeakTable<K, V> that we use when targeting .NET Standard 2.0 and below, so thankfully this bug doesn't affect all consumers of the MVVM Toolkit today. Eventually all this code will just be removed once we drop UWP and .NET Standard 2.0 and below entirely. But of course, right now this bug would affect UWP consumers (or anything else on older runtimes), so totally a good catch! 🎉
Activity
michael-hawker commentedon Jun 22, 2021
FYI @Sergio0694 thoughts on this?
Sergio0694 commentedon Jun 22, 2021
Oh, good catch @steinhilber, thanks!
I had missed the fact that removing a
LinkedListNode<T>also did side-effect on the node and cleared it 😄@michael-hawker Just to add some more context here, this bug only affects the polyfill for
ConditionalWeakTable<K, V>that we use when targeting .NET Standard 2.0 and below, so thankfully this bug doesn't affect all consumers of the MVVM Toolkit today. Eventually all this code will just be removed once we drop UWP and .NET Standard 2.0 and below entirely. But of course, right now this bug would affect UWP consumers (or anything else on older runtimes), so totally a good catch! 🎉Fix register/unregister issues of WeakReferenceMessenger (#4082)