Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ContentDialog showAsync() giving error: no definition for getAwaiter [duplicate]

I am building an UWP app (C#) and on click of button, I want to verify input. If verification fails, I want to display a message saying that there is wrong input. this is my function which should handle this:

private async void AddContact_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
    DBHelper db = new DBHelper();
    if(i_name.Text != "" && i_phone.Text != "") {
        db.insertPerson(new Person(i_name.Text, i_phone.Text));
        Frame.Navigate(typeof(MainPage));
    } else {
        ContentDialog msg = new ContentDialog() {
            Title = "Empty input!",
            Content = "Please fill both fields!",
            CloseButtonText = "OK"
        };
        await msg.ShowAsync();
    }
}

However, when the last part (await msg.showAsync() ) is typed it stays underlined in red (in VS). The builder reads the following error:

Error CS4036 'IAsyncOperation' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation' could be found (are you missing a using directive for 'System'?) testniStudioApp d:...\SecondPage.xaml.cs 43 Active

Now i tried to assign this call to variable (as I saw that someone solved similiar problem that way), but it still didn't worked. Then I tried clearing NuGet cache and rebuilding project as stated here, but none of those solutions worked.

I have a hard time understanding what it wants from me. Every single tutorial on how to display message was written in more or less the same manner, so I can't understand what can be wrong.

like image 948
Miha Jamsek Avatar asked Jan 04 '23 23:01

Miha Jamsek


1 Answers

using System; was mising. Thanks to comments for answer

like image 109
Miha Jamsek Avatar answered Jan 06 '23 14:01

Miha Jamsek