CommunityToolkit / CommunityToolkit/dotnet

Messenger keeps stacking messages even it is unregistered

Open
#1,103 1 comment 1 reaction 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

I have come through this bug and did not find a solution for it, even AI was unable to answer me. So, I think it is a bug in the library.
I have created a sample repo as well as a video showing the behaviour.
The issue in short, is that when you register StrongReferenceMessenger and then unregister it, when you open it again previous messengers registrations will be invoked and stacking messages are in place.

Here is the repo to reproduce

https://github.com/JawadJaber/WpfTestStrongReferenceMessengerStackingIssue

### Regression

_No response_

### Steps to reproduce

https://github.com/user-attachments/assets/d0d69615-8445-46c2-a935-b4985683655a

### Expected behavior

When creating new window twice, the logger should receive only one line message not two.

### Screenshots

_No response_

### IDE and version

VS 2022

### IDE version

_No response_

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [x] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.4.0

### Additional context

_No response_

### Help us help you

Yes, I'd like to be assigned to work on this item

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.