Xamarin 表单:加载页面时显示 DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT
Xamarin forms: Showing DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT when loading a page
在 xamarin UWP 中加载页面时重定向到 App.g.i.cs
。代码控制来到下面的if block.
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
如果我将鼠标悬停在 e 上显示 {Windows.UI.Xaml.UnhandledExceptionEventArgs}
我不明白这是什么问题?这与 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>
和Xamarin.forms 3.x Microsoft moved to .net standard 2.0。
我能够在您的 XAML 文件中编译代码和 运行 应用 after converting your PCL to .net standard 2.0, updating all nuget packages to last version and changing xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
to xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
as stated in the documentation。
单击 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
中,您对 username 和 password.
犯了同样的错误
也改
所以重置有效:
真正的问题在于 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");
});
在 xamarin UWP 中加载页面时重定向到 App.g.i.cs
。代码控制来到下面的if block.
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
如果我将鼠标悬停在 e 上显示 {Windows.UI.Xaml.UnhandledExceptionEventArgs}
我不明白这是什么问题?这与 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>
和Xamarin.forms 3.x Microsoft moved to .net standard 2.0。
我能够在您的 XAML 文件中编译代码和 运行 应用 after converting your PCL to .net standard 2.0, updating all nuget packages to last version and changing xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
to xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
as stated in the documentation。
单击 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
中,您对 username 和 password.
也改
所以重置有效:
真正的问题在于 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");
});