无法捕获System.TypeLoadException:Xamarin表单中的<超时超出了获取异常的详细信息>

时间:2019-09-08 18:26:01

标签: c# .net xamarin xamarin.forms xamarin.android

我正在初始化导航页面,如下所示:

public App()
{
    InitializeComponent();

    MainPage = new NavigationPage(new MainPage());
}

这是MainPage XAML代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage Title="Introduction" xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="LearningXamarin.MainPage">
    <StackLayout>
        <Button Text="Next" Clicked="Button_Clicked"/>
    </StackLayout>
</ContentPage>

MainPage.xaml.cs代码:

async private void Button_Clicked(object sender, EventArgs e)
{
    try { 
        await Navigation.PushAsync(new NextPage());
    }
    catch (Exception)
    {
          throw;
    }
}

现在,当我单击此按钮时,它将引发Unable to catch System.TypeLoadException: <Timeout exceeded getting exception details>。我尝试添加Try..Catch块,但未显示异常详细信息。

NextPage.xaml代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage Title="Next" xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="LearningXamarin.NextPage">


</ContentPage>

NextPage.xaml.cs代码:

public partial class NextPage : ContentPage
{
    public NextPage()
    {
        try
        {
            InitializeComponent();
        }
        catch(Exception)
        {
            throw;
        }
    }
}

0 个答案:

没有答案