Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Forms App OnStart() iOS - NullReferenceException FormsApplicationDelegate.UpdateMainPage()

$
0
0

I have a xamarin.forms app that is working fine on Android and I had working fine on iOS. Recently I have started bringing the iOS side up to date with the Android version and have run into an issue.

Here is the App class:

public partial class App : Application
{
    public App ()
    {
        InitializeComponent ();
    {
}

protected override void OnStart ()
{
    try
    {
        var page = new Home ();
        page.BackgroundColor = Color.FromHex ("#F3F2F0");
        var nav = new NavigationPage (page);
        nav.BarBackgroundColor = Color.FromHex ("#1A4C70");
        nav.BarTextColor = Color.White;
        this.MainPage = nav;
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
        System.Diagnostics.Debug.WriteLine(ex.StackTrace);
    }
}

Debugging from Visual Studio through a Mac BuildHost the app crashes with a nullreferenceexception on the same line (inside my try block). It doesn't matter what code is in that line, it fails the same way with the same error. Breaking at that point doesn't show any null values. It started with

this.MainPage = nav;

but I added the try-catch and it still errors the same way. Any help would be appreciated!

StackTrace:

2015-04-09 14:17:24.402 SheriffAppFormsiOS[2676:60128] Unhandled managed exception: Object reference not set to an instance of an object     (System.NullReferenceException)
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.UpdateMainPage () [0x00000] in <filename unknown>:0 
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.ApplicationOnPropertyChanged (System.Object sender,     System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in <filename unknown>:0 
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in <filename unknown>:0 
at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x00000] in <filename unknown>:0 
at SheriffAppForms.App.OnStart () [0x0003c] in c:\Users\italletg\Source\Repos\Spectre\SheriffAppForms\App.xaml.cs:30 
at Xamarin.Forms.Application.SendStart () [0x00000] in <filename unknown>:0 
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDic

tionary launchOptions) [0x00000] in :0


Viewing all articles
Browse latest Browse all 89864

Trending Articles