Skip to content

COMException in Clipboard.TryGetDataAsync #21296

Description

@Symbai

Describe the bug

System.Runtime.InteropServices.COMException: Unexpected HRESULT has been returned from a call to a COM component.
  Module "Avalonia.Win32.ClipboardImpl.<TryGetDataAsync>d__9"

Looking at the source code there is no try catch. So whenever it fails for whatever reason it crashes the entire application. Happened in 11.3.x but since there is still no try-catch this also applies to the most recent version.
And Textbox.Paste is async void which isn't good for dealing with exceptions either.

To Reproduce

Block clipboard through another process, i.e. password manager
Try paste text into a textbox in Avalonia

Expected behavior

No response

Avalonia version

11.3.x

OS

Windows

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions