Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Identifier Not Found #161

Closed
Mliybs opened this issue Sep 13, 2023 · 5 comments
Closed

Bug: Identifier Not Found #161

Mliybs opened this issue Sep 13, 2023 · 5 comments

Comments

@Mliybs
Copy link

Mliybs commented Sep 13, 2023

I got a crush when I use the Android verision of my app. When I was debugging it on my computer, I got the exception message:

InvalidOperationException: No Loaded DialogHost have an Identifier property matching dialogIdentifier (The Identifier)

It happened at DialogHost.Close(String dialogIdentifier) when I had just closed a message box, opening the second one(using await).

It only happens when the two boxes both use ShowAsPopupAsync.

I found that the the bug may be caused by the SetCloseAction in MsBox class. When the first one is going to be closed, the TrySetResult method is invoked, then the second one is opened, but the first have not been closed, it made the first cannot be found with the identifier and caused the crush.

When I use await Task.Delay(10) between two boxes or let the TrySetResult method be invoked after the DialogHost.Close, it never happens again.

I'm a Chinese student, if my words are wrong at somewhere, please let me know.

By the way, I would like to create a pull request if needed :D

@Mliybs
Copy link
Author

Mliybs commented Sep 13, 2023

2023-09-13 21-16-33 的屏幕截图
A picture of the bug

@CreateLab
Copy link
Member

CreateLab commented Oct 24, 2023

  1. update to actual version, if bug reproduce please give an some code example
@Mliybs
Copy link
Author

Mliybs commented Oct 24, 2023

  1. update to actual version, if bug reproduce please give an some code example

thx :D

@Mliybs Mliybs closed this as completed Oct 24, 2023
@shaosu
Copy link

shaosu commented Nov 26, 2023

Exception when calling ShowAsPopupAsync twice

private async void CustomInputPasswdValue_OnClick(object sender, RoutedEventArgs e)
{
    ButtonDefinition[] buttons = new ButtonDefinition[2];
    buttons[0] = new ButtonDefinition() { IsDefault = true, Name = "OK" };
    buttons[1] = new ButtonDefinition() { IsCancel = true, Name = "Cancel" };
    var CustomParam = new MessageBoxCustomParams
    {
        ContentTitle = "Custom Input Passwd Value",
        ContentMessage = $"Please enter a string",
        Icon = MsBox.Avalonia.Enums.Icon.Info,
        InputParams = new InputParams() { Label = "Passwd:", DefaultValue = "AAA" }, // , PasswordChar = "*"
        ButtonDefinitions = buttons,
    };

    var box = MessageBoxManager.GetMessageBoxCustom(CustomParam);
    var result = await box.ShowAsPopupAsync(this); // Fail:On box2 ShowAsPopupAsync
    // System.InvalidOperationException:“No loaded DialogHost have an Identifier property matching dialogIdentifier ('MsBoxIdentifier4931f5a5-d63a-4814-8613-8e3870df1497') argument.”
    string InputValue = box.InputValue;
    box = null;
    if (result == "OK")
    {
       var box2 = MessageBoxManager.GetMessageBoxStandard("Caption", $"Your passwd value is:{InputValue}", ButtonEnum.Ok);
       await box2.ShowAsPopupAsync(this);
    }
}
@CreateLab
Copy link
Member

@shaosu please open new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants