Bug 22084 - UpdateIdValues throwing NullReferenceException in Styleable constructor
Summary: UpdateIdValues throwing NullReferenceException in Styleable constructor
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.14.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-08-13 19:54 UTC by Tom Gilder
Modified: 2014-08-26 09:37 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
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 INVALID

Description Tom Gilder 2014-08-13 19:54:05 UTC
Every time I change an ID of any resource in my project, I get a NullReferenceException thrown by Android.Runtime.ResourceIdManager.UpdateIdValues on app start, unless I clean or rebuild the project first. 

Will try to come up with example project.


Exception:


{System.NullReferenceException: Object reference not set to an instance of an object
  at Android.Runtime.ResourceIdManager.UpdateIdValues () [0x000b4] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.14-series/8e79d361/source/monodroid/src/Mono.Android/src/Runtime/ResourceIdManager.cs:26 
  at ThisRadio.Android.Resource+Styleable..cctor () [0x0005d] in /Users/tom/Projects/ThisRadio/src/ThisRadio.Android/Resources/Resource.designer.cs:259 }
	Static members: 
	Non-public members: 
 	Data: Count=0
 	HResult: -2147467261
 	HelpLink: (null)
 	InnerException: (null)
 	Message: "Object reference not set to an instance of an object"
 	Source: "Mono.Android"
 	StackTrace: "  at Android.Runtime.ResourceIdManager.UpdateIdValues () [0x000b4] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.14-series/8e79d361/source/monodroid/src/Mono.Android/src/Runtime/ResourceIdManager.cs:26 \n  at ThisRadio.Android.Resource+Styleable..cctor () [0x0005d] in /Users/tom/Projects/ThisRadio/src/ThisRadio.Android/Resources/Resource.designer.cs:259 "
 	TargetSite: {Void UpdateIdValues()}
Comment 1 Udham Singh 2014-08-25 14:44:49 UTC
We have tried to reproduce this issue but not able to reproduce this. Could you please provide a sample project/ test case , so that we can reproduce this issue at our end.
Comment 2 Jonathan Pryor 2014-08-25 15:11:16 UTC
Relevant code is:

>	if (t != null)
>		t.GetMethod ("UpdateIdValues").Invoke (null, new object [0]);

The `t.GetMethod().Invoke()` is ResourceIdManager.cs:26.

So this could plausibly happen if the type found doesn't have an UpdateIdValues() method.

`t` in turn is a System.Type that comes from Reflection for all assemblies in the process which have [assembly:ResourceDesigner("FullyQualifiedTypeName", IsApplication=true)] (and there should be only one), from the Application project, and FullyQualifiedTypeName is the name of the generated Resource class which contains the UpdateIdValues() method.

I'm not sure how this could fail, short of manually mucking about with generated code...
Comment 3 Tom Gilder 2014-08-26 09:37:09 UTC
Sorry, I'm an idiot. I have NullGuard.Fody installed, and didn't consider that it was rewriting the generated code.