Skip to content

'ComWrappers.ReleaseObjects' also passes aggregated objects #114043

Closed
@Sergio0694

Description

@Sergio0694

Related to microsoft/CsWinRT#1955

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

  1. Run https://github.com/user-attachments/files/19464189/App1.zip
  2. Click the button to open a page
  3. Click the button to close the window
  4. Observe the crash

Image

Expected behavior

Not clear.

Actual behavior

ComWrappers.ReleaseObject is also receiving some aggregated objects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions