Maui for Android issue with Clipboard.Default.SetTextAsync

Haviv Elbsz 2,071 Reputation points
2024-07-11T13:02:57.0366667+00:00

Hello all the code for

Clipboard.Default.SetTextAsync

as shown build ok but croush

at app starting. Any help

Thank you.

Using maui and android latest versions.

private void TDRangeTB_TextChanged(object sender, TextChangedEventArgs e)

{

  if(IsAppRunning) return;

  TDRangeCKB.IsChecked = false;

  if(TDRangeCKB.IsChecked == true) TDRangeTB.Text = "";

  if(Regex.IsMatch(TDRangeTB.Text, @"^\s*((\d{1,2}\s+){3,}[=!]\s*)*\s*$"))

  {

    TDRangeTB.TextColor = Colors.Black;

  }

  else

  {

    TDRangeTB.TextColor = Colors.Red;

    TDRangeCKB.IsChecked = false;

    return;

  }

  if(!Regex.IsMatch(TDRangeTB.Text, @"^\s*((\d{1,2}\s+){3,}[=!]\s*)*\s*$")) TDRangeCKB.IsChecked = false;

  if(TDRangeTB.Text.Length > 3)

     MainThread.BeginInvokeOnMainThread(async () => {await Clipboard.Default.SetTextAsync(TDRangeTB.Text);});

}

crouch after sowing Splash Screen and before showing UI screen

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,369 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 30,416 Reputation points Microsoft Vendor
    2024-07-15T01:52:45.2066667+00:00

    Hello,

    As you @Haviv Elbsz said, you solved the problem by deleting the bin and obj and recreating the emulator. Thanks again for your sharing.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.