Bootstrapper HandleResuming null reference exception
I have an app in the store running 1.1.11. I am seeing a lot of null reference exceptions:
Exception Type: System.NullReferenceException
Crashed Thread: 2
Application Specific Information:
Arg_NullReferenceException
Exception Stack:
Csn.UniversalWindows!<BaseAddress>+0xa6a833
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
SharedLibrary!<BaseAddress>+0x69993e
SharedLibrary!<BaseAddress>+0x497d7c
Csn.UniversalWindows!<BaseAddress>+0x93eb5c
Csn.UniversalWindows!<BaseAddress>+0x969846
Csn.UniversalWindows!<BaseAddress>+0x969774
Microsoft.HockeyApp.Extensibility.Windows.UnhandledExceptionTelemetryModule.CoreApplication_UnhandledErrorDetected(Object sender, ApplicationModel.Core.UnhandledErrorDetectedEventArgs e)
Thread 2 Crashed:
0 Csn.UniversalWindows 0x00007ff98f27a833 Template10.Common.BootStrapper.<HandleResuming>d__99.MoveNext() in at 0:0
1 SharedLibrary 0x00007ff98e4c12b1 0x00007ff98e070000 + 4526769
2 SharedLibrary 0x00007ff98e70993e 0x00007ff98e070000 + 6920510
3 SharedLibrary 0x00007ff98e507d7c 0x00007ff98e070000 + 4816252
4 Csn.UniversalWindows 0x00007ff98f14eb5c McgInterop.McgHelpers.ThrowFailed(Int32 hr, RuntimeTypeHandle typeHnd) in c:\windows\ServiceProfiles\NetworkService\appdata\local\packages\appcompile-20160614-164754-20384\ac\Temp\Ilc924988408\Csn.UniversalWindows.McgInterop\Helpers.g.cs at 5322:10
5 Csn.UniversalWindows 0x00007ff98f179846 McgInterop.ComCallHelpers.ComCall__HRESULT($__ComObject __this, RuntimeTypeHandle __typeHnd, Int32 __targetIndex) in c:\windows\ServiceProfiles\NetworkService\appdata\local\packages\appcompile-20160614-164754-20384\ac\Temp\Ilc924988408\Csn.UniversalWindows.McgInterop\SharedStubs.g.cs at 5970:5
6 Csn.UniversalWindows 0x00007ff98f179774 McgInterop.ForwardComSharedStubs.Proc_<System.__Canon>(Void* InstParam, $__ComObject __this, Int32 __targetIndex) in c:\windows\ServiceProfiles\NetworkService\appdata\local\packages\appcompile-20160614-164754-20384\ac\Temp\Ilc924988408\Csn.UniversalWindows.McgInterop\SharedStubs.g.cs at 636:4
7 Csn.UniversalWindows 0x00007ff98f273d63 Microsoft.HockeyApp.Extensibility.Windows.UnhandledExceptionTelemetryModule.CoreApplication_UnhandledErrorDetected(Object sender, $UnhandledErrorDetectedEventArgs e) in at 0:0
These exceptions are happening on an array of different devices both PC and mobile. Has anyone had similar issues, may know what is causing it ? I have failed to reproduce on multiple test devices.
Please keep chasing this. Give me some hints on where to look into if there's an issue.
I've been looking into this and I think I might have cracked it. In my application I was making the NavigationServiceFactory call inside OnInitializeAsync. When the app is activated through prefetch in some cases the app gets suspended before the call to NavigationServiceFactory completes (or before its even reached since I had some code before it) therefore when the user launches the app and NavigationService is invoked from OnStartAsync it is null.
Now I'm calling the NavigationServiceFactory inside CreateRootElement and moved a lot of the code that was in OnInitializeAsync to OnStartAsync. I have deployed a new version to the store yesterday and so far it looks promising, haven't seen the null reference exception yet. I will monitor for a couple of days if its all good I will close the issue.
Brilliant.