在xamarin UWP中加载页面时重定向到App.g.i.cs
。代码控制来自以下if块。
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
如果我将鼠标悬停在显示{Windows.UI.Xaml.UnhandledExceptionEventArgs}
的 e 上
我不明白这是什么问题?这与XAML中的某些错误有关吗?仅在Windows应用程序上存在此问题,Android和IOS应用程序部分运行正常。
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"
x:Class="Myproject.Pages.CodeValidationPage"
BackgroundColor="#00aff0">
<ScrollView>
<StackLayout
VerticalOptions="FillAndExpand">
<StackLayout
VerticalOptions="CenterAndExpand"
Orientation="Vertical">
<Image
Source="splash.png"
HeightRequest="120"
WidthRequest="120"
IsVisible="True"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"/>
<Label
Text=" Please check your email for the verification code and activate your account. "
HorizontalOptions="CenterAndExpand"
x:Name="italic_test"
HorizontalTextAlignment="Center"
Margin="3"
Font="Italic,15"
TextColor="White"/>
<Frame
HorizontalOptions="FillAndExpand"
CornerRadius="10"
Margin="20"
Padding="0">
<StackLayout
BackgroundColor="White"
Orientation="Vertical"
VerticalOptions="CenterAndExpand" >
<Entry
x:Name="codeentry"
Margin="10,10,10,0"
Keyboard="Numeric"
Placeholder="Enter Verification Code"/>
<Entry
x:Name="passwordentry"
Placeholder="Password"
IsVisible="False"
Margin="10,10,10,0"
IsPassword="True"/>
<Entry
x:Name="confirmpasswordentry"
Margin="10,0,10,-10"
IsVisible="False"
Placeholder="Confirm Password"
IsPassword="True"/>
<Button
Text="Verify Code"
HeightRequest="40"
WidthRequest="150"
x:Name="validationButton"
TextColor="White"
HorizontalOptions="CenterAndExpand"
Font="Bold,15"
Margin="5,15,5,10"
BorderRadius="20"
BackgroundColor="#00aff0"
Clicked="SaveNewPassword"/>
</StackLayout>
</Frame>
</StackLayout>
<Label
VerticalOptions="EndAndExpand"
HorizontalOptions="CenterAndExpand"
Margin="0,0,0,15"
x:Name="backto_label"
TextColor="White"
Font="Bold,16"
Text=" Back to Sign Up "/>
</StackLayout>
</ScrollView>
</ContentPage>
答案 0 :(得分:2)
使用Xamarin.forms 3.x Microsoft moved to .net standard 2.0。
我能够编译代码并运行应用程序after converting your PCL to .net standard 2.0,将所有nuget软件包更新为最新版本,并将XAML文件中的xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
更改为stated in the documentation的xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
单击ResetPassword在此行显示System.Collections.Generic.KeyNotFoundException:
string initialLogin = Application.Current.Properties["initialLogin"].ToString();
因此将其更改为
Application.Current.Properties.TryGetValue("initialLogin", out var initialLogin);
处理未将“ initialLogin ”添加到Application.Current.Properties集合的情况。接下来,请在使用前检查其值为!= null
。
在Mainpage.xaml.cs
中,您也用用户名和密码犯了同样的错误。
还要更改PDB type from full to pdb-only to allow debugging. This is a known issue.
所以重置有效:
答案 1 :(得分:0)
真正的问题在于disaplayalert
。
我将以下代码用于显示警报:
await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");
如果我像下面那样更改以上行,则不会出现任何问题。
Device.BeginInvokeOnMainThread(async () =>
{
await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");
});