Description
It seems that ComWrappers.ReleaseObjects is called with some objects also potentially being aggregated objects (eg. a type deriving from Windows.UI.Xaml.Controls.Page). This currently causes CsWinRT to throw an exception, as we can't unwrap the object. That is by design, as our understanding was that ReleaseObjects would only be called with unwrappable RCWs from our own ComWrappers.
I'm not sure whether this is a bug or expected. It feels like at the very least we could improve the docs for ReleaseObjects? Currently the method is pretty cryptic, as it just takes some IEnumerable and gives you no info whatsoever on when would the method actually be called, or what objects an implementing type should expected to be passed to it, and/or what should the behavior be for objects you can't manually release.
Reproduction Steps
- Run https://github.com/user-attachments/files/19464189/App1.zip
- Click the button to open a page
- Click the button to close the window
- Observe the crash

Expected behavior
Not clear.
Actual behavior
ComWrappers.ReleaseObject is also receiving some aggregated objects.
Related to microsoft/CsWinRT#1955
Description
It seems that
ComWrappers.ReleaseObjectsis called with some objects also potentially being aggregated objects (eg. a type deriving fromWindows.UI.Xaml.Controls.Page). This currently causes CsWinRT to throw an exception, as we can't unwrap the object. That is by design, as our understanding was thatReleaseObjectswould only be called with unwrappable RCWs from our ownComWrappers.I'm not sure whether this is a bug or expected. It feels like at the very least we could improve the docs for
ReleaseObjects? Currently the method is pretty cryptic, as it just takes someIEnumerableand gives you no info whatsoever on when would the method actually be called, or what objects an implementing type should expected to be passed to it, and/or what should the behavior be for objects you can't manually release.Reproduction Steps
Expected behavior
Not clear.
Actual behavior
ComWrappers.ReleaseObjectis also receiving some aggregated objects.