Bug 60337 - Null Reference Exception in LoadApplication in FormsAppCompatActivity (NRE) due to changes from #59882
Summary: Null Reference Exception in LoadApplication in FormsAppCompatActivity (NRE) d...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 60346 ()
Depends on:
Blocks:
 
Reported: 2017-10-23 20:14 UTC by Almando
Modified: 2017-10-27 17:38 UTC (History)
5 users (show)

Tags: ac fr
Is this bug a regression?: Yes
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Almando 2017-10-23 20:14:15 UTC
Exception on during LoadApplication() in FormsAppCompatActivity.cs due to the following recent code addition:

var iver = Platform.GetRenderer(application.MainPage); // Offending line.
if (iver != null)
{
	iver.Dispose();
	application.MainPage.ClearValue(Platform.RendererProperty);
}


Prior to 2.4.0 R2, Application.MainPage could be null until OnStart() was called and now causes NRE if not set during LoadApplication(new App(..));s.Platform.Android\AppCompat\FormsAppCompatActivity.cs:152
Comment 1 Chris King 2017-10-23 20:31:25 UTC
Sorry about that. https://github.com/xamarin/Xamarin.Forms/pull/1221
Comment 2 Almando 2017-10-23 20:32:44 UTC
Not Application
* MainPage
Comment 3 Almando 2017-10-23 20:38:16 UTC
The property MainPage in the Application class was able to be null prior to OnStart(). 

The NRE happens inside Platform.GetRenderer(..) when passed in a null 'MainPage'.
Comment 4 Paul DiPietro [MSFT] 2017-10-24 14:36:29 UTC
*** Bug 60346 has been marked as a duplicate of this bug. ***
Comment 5 RockStar 2017-10-24 17:43:26 UTC
I have this error after update to XF 2.4.0.18342.
Comment 6 Wallace Santos 2017-10-24 18:46:04 UTC
I have this bug (or something like as) in version 2.4.0.18342. (See Bug 60346 I submitted today).
Comment 7 Samantha Houts [MSFT] 2017-10-27 17:38:23 UTC
Should be fixed in 2.4.0 SR3. Thank you!