Forum Xamarin.Forms

Xamarin.Forms.Platform.WinPhone.FormsApplicationPage.OnDeactivated null reference exception

ToemselToemsel USMember ✭✭

When the application loses his focus (e.g. open the browser) following exception will be thrown:

System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.WinPhone.FormsApplicationPage.OnDeactivated(Object sender, DeactivatedEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Microsoft.Phone.Shell.PhoneApplicationService.FireDeactivated(UInt32 reason)
at Microsoft.Phone.TaskModel.Interop.ITask.Pause.Invoke(UInt32 reason)
at Microsoft.Phone.TaskModel.Interop.Task.FireOnPause(UInt32 reason)

I didnt modify the App.xaml:

<Application.ApplicationLifetimeObjects>
    
    <shell:PhoneApplicationService
        Launching="Application_Launching" Closing="Application_Closing"
        Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>

After the defined method "Application_Deactivated" has been called, the application crashes.
(There isnt any code in that method who could cause anything)

Answers

  • Liger_JeromeLiger_Jerome FRUniversity ✭✭

    I have the exactly same problem...
    error at : Microsoft.Phone.Shell.PhoneApplicationService.FireDeactivated

    I don't know if this could be helpfull, but I have many "OS-interraction" in my Xamarin.Forms App with an Interface in PCL, and implementation on each platform, that call (for windows phone example) SaveContactTask, SaveContactTask, EmailComposeTask, etc...
    No problem on Androïd and iOS, but in WindowsPhone, whatever the method I call, I got an error on "Application_Deactivated" and the app crash...

    Is there anything that I forgot ? (I don't have any code in the "Application_Deactivated" method either)
    Is this a bug in Xamarin.Forms ?

    My version of Xamarin.Forms is V1.5.1.6471...

    Any help ?

    Thanks

  • Liger_JeromeLiger_Jerome FRUniversity ✭✭

    Edit : in my case, this come from a "bugged-version" of Xamarin.Insights in the "suspended"

    https://forums.xamarin.com/discussion/52246/crash-when-backgrounding-on-windows-phone

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    From looking at the code I can only see this happening if you never call LoadApplication

Sign In or Register to comment.