You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin.Forms Shell应用点击按钮触发TargetInvocationException报错求助

Xamarin.Forms Shell应用iOS端页面跳转异常求助

在Mac版Visual Studio中运行Xamarin.Forms Shell应用时,点击页面跳转按钮会弹出「Exception Caught」提示,报错指向Main.cs第15行,应用其余功能均可正常运行。

相关代码

Main.cs(报错行标注)

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace Rollthedice3._0.iOS
{
    public class Application
    {
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            UIApplication.Main(args, null, typeof(AppDelegate)); // 第15行,报错指向此处
        }
    }
}

触发异常的LoginPage XAML代码

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="Rollthedice3._0.Views.LoginPage"
             Shell.NavBarIsVisible="False">

    <ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
        </Grid.RowDefinitions>
           
        <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackLayout BackgroundColor="{StaticResource Accent}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill">
            </StackLayout>
        </Grid>
    </ContentPage.Content>
</ContentPage>

恳请各位提供该异常的解决方法。

内容的提问来源于stack exchange,提问作者Jace

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 09:45:25