我正在初始化导航页面,如下所示:
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;
}
}
}