Skip to content

CompositionTarget.Rendering throws InvalidCastException #7247

Closed

Description

Describe the bug

When we hook into the CompositionTarget.Rendering event we're seeing an InvalidCastException native exception thrown (seems continuable though):

System.InvalidCastException
  HResult=0x80004002
  Message=Specified cast is not valid.
  Source=WinRT.Runtime
  StackTrace:
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)

This doesn't happen on UWP, though I'm not sure if we're actually getting the proper behavior of waiting on WinUI 3.

Saw both on WinAppSDK 1.0.3 and 1.1.1.

Steps to reproduce the bug

Hook into the Composition.Rendering event

You can also include the CommunityToolkit.WinUI.UI 7.1.2 package and use our CompositionTargetHelper static method helper.

Expected behavior

No exception thrown.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.1.1

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

Activity

  1. ghost added
    needs-triage
    on Jun 16, 2022
  2. added
    team-Rendering
    on Jun 22, 2022
  3. removed
    needs-triage
    on Dec 7, 2022
  4. michael-hawker commented on Jul 13, 2023

    @michael-hawker
    ContributorAuthor

    Assume this is still an issue, but would have to look on latest. Bumping, based on #8638

  5. JJBrychell commented on Aug 29, 2023

    @JJBrychell

    Unable to repro this on any version 1.1 to 1.3 using the CompositionTargetHelper class in included in comments. Also the report doesn't indicate whether the error is occurring when attempting to assign the event handler or when the event handler is being executed.

    If this continues to be an issue feel free to reopen with more a more actionable repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugproduct-winui3team-Renderingwct

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions