指定的 child 已经有一个 parent。您必须先在 child 的 parent 上调用 removeView()。”面对这个问题

The specified child already has a parent. You must call removeView() on the child's parent first." Facing this issue

我使用了 MAUI 预览版和 VS 2022。当应用程序为 运行 并使用了所有功能并按下系统后退按钮并关闭 app.After 关闭应用程序时,我正在尝试 oepn当时的应用

"{Java.Lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
" 

发生在我​​的 mainActivity 页面上。

    protected override void OnCreate(Bundle savedInstanceState)
    {
        try
        {
            // TEXTVIEW

            base.OnCreate(savedInstanceState);                           
            initFontScale();
            Microsoft.Maui.Essentials.Platform.Init(this, savedInstanceState);
            UserDialogs.Init(this);
            //Microsoft.Maui.Essentials.Platform.Init(this, savedInstanceState);
        }
        catch (System.Exception ex)
        {
        }
    }

如何解决此错误。

似乎有人报告了这一点,根据那里的评论,这应该在预览版 11+ 中得到修复:github。com/dotnet/maui/issues/3511 你安装了哪个 VS2022?

安装 Visual Studio 2022 v17.1 Preview 2 应该会为您提供 .NET MAUI Preview 11,这应该可以解决问题。