简体   繁体   English

序列在System.Linq.Enumerable.Last不包含匹配元素<Xamarin.Forms.Page>

[英]Sequence contains no matching element at System.Linq.Enumerable.Last<Xamarin.Forms.Page>

I use Xamarin.Forms: 我使用Xamarin.Forms:

protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);
    global::Xamarin.Forms.Forms.Init (this, bundle);
    LoadApplication (new App ());
    SetContentView(Resource.Layout.Main);
    AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironmentUnhandledExceptionRaiser;
}

private void AndroidEnvironmentUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
{
    string str = e.Exception.ToString();
}

I press 'Escape' ('Back') button and have this exception: 我按“转义”(“后退”)按钮,但有以下异常:

e.Exception { System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.Last (System.Collections.Generic.IEnumerable 1<Xamarin.Forms.Page>,System.Func 2,System.Linq.Enumerable/Fallback) <0x00364> at System.Linq.Enumerable.Last (System.Collections.Generic.IEnumerable`1) <0x0028b> at Xamarin.Forms.Platform.Android.Platform.HandleBackPressed (object,System.EventArgs) at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnBackPressed () at Android.App.Activity.n_OnBackPressed (intptr,intptr) [0x00009] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1987 at (wrapper dynamic-method) object.56117541-8b13-4e27-96fb-c2b57f6bfd8a (intptr,intptr) } System.InvalidOperationException e.Exception {System.InvalidOperationException:序列在System.Linq.Enumerable.Last(System.Collections.Generic.IEnumerable 1<Xamarin.Forms.Page>,System.Func 2,System.Linq.Enumerable / Fallback处不包含匹配元素)在System.Linq.Enumerable.Last(System.Collections.Generic.IEnumerable`1)的<0x00364>在Xamarin.Forms.Platform.Android.Platform.HandleBackPressed(object,System.EventArgs)在Xamarin.Forms的<0x0028b> /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms中的Android.App.Activity.n_OnBackPressed(intptr,intptr)[0x00009]上的Platform.Android.FormsApplicationActivity.OnBackPressed() /android-15/src/generation/Android.App.Activity.cs:1987 at(包装动态方法)object.56117541-8b13-4e27-96fb-c2b57f6bfd8a(intptr,intptr)} System.InvalidOperationException

You don't need to call both LoadApplication() and SetContentView(). 您无需同时调用LoadApplication()和SetContentView()。 In a Forms app, LoadApplication() will set the initial view in your app using the shared Forms UI. 在Forms应用程序中,LoadApplication()将使用共享的Forms UI在您的应用程序中设置初始视图。

If you are building an Android only app, then use SetContentView(). 如果要构建仅Android应用程序,请使用SetContentView()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM