Bug 21158 - NullReferenceException when calling UINavigationBarAppearance.SetTitleTextAttributes
Summary: NullReferenceException when calling UINavigationBarAppearance.SetTitleTextAtt...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.2.5
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-07-07 15:51 UTC by Frank A. Krueger
Modified: 2014-07-07 18:05 UTC (History)
2 users (show)

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:

Description Frank A. Krueger 2014-07-07 15:51:01 UTC
Since updating to the latest Stable these line of code fails:

UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes {
				Font = Theme.TitleFont,
				TextColor = Theme.TitleColor,

Please advise how to work around this.

Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
	  at MonoTouch.ObjCRuntime.Runtime.NativeObjectHasDied (IntPtr ptr, IntPtr managed_ptr) [0x00000] in <filename unknown>:0 
	  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:NativeObjectHasDied (intptr,intptr)
	  at (wrapper managed-to-native) MonoTouch.Foundation.NSObject:monotouch_release_managed_ref (intptr,intptr)
	  at MonoTouch.Foundation.NSObject.ReleaseManagedRef () [0x00000] in <filename unknown>:0 
	  at MonoTouch.Foundation.NSObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
	  at MonoTouch.Foundation.NSObject.Dispose () [0x00000] in <filename unknown>:0 
	  at MonoTouch.UIKit.UITextAttributes.ToDictionary () [0x00000] in <filename unknown>:0 
	  at MonoTouch.UIKit.UINavigationBar+UINavigationBarAppearance.SetTitleTextAttributes (MonoTouch.UIKit.UITextAttributes attributes) [0x00000] in <filename unknown>:0 
	  at Mocast.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00000] in <filename unknown>:0 
	  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
	  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principal

Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x38ae01f0 __pthread_kill + 8
1   libsystem_pthread.dylib       	0x38b487b3 pthread_kill + 55
2   libsystem_c.dylib             	0x38a90ff5 abort + 73
3   Mocast                        	0x00655f89 mono_handle_native_sigsegv (mini-exceptions.c:2341)
4   Mocast                        	0x0065ac7b sigabrt_signal_handler (mini-posix.c:206)
5   libsystem_platform.dylib      	0x38b43721 _sigtramp + 41
6   libsystem_pthread.dylib       	0x38b487b3 pthread_kill + 55
7   libsystem_c.dylib             	0x38a90ff5 abort + 73
8   Mocast                        	0x00700204 monotouch_unhandled_exception_handler (monotouch-glue.m:1562)
9   Mocast                        	0x0065635d mono_invoke_unhandled_exception_hook (mini-exceptions.c:2670)
10  Mocast                        	0x006619c3 mono_thread_abort_dummy (mini.c:2821)
11  Mocast                        	0x00655d17 mono_handle_exception_internal (mini-exceptions.c:1697)
12  Mocast                        	0x00654d9f mono_handle_exception (mini-exceptions.c:1921)
13  Mocast                        	0x0064fe15 handle_signal_exception (exceptions-arm.c:529)
14  Mocast                        	0x00319090 MonoTouch.ObjCRuntime.Runtime:NativeObjectHasDied (Runtime.cs:671)
15  Mocast                        	0x0033a738 (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:NativeObjectHasDied + 72
16  Mocast                        	0x006ffa94 monotouch_release_managed_ref (monotouch-glue.m:1378)
17  Mocast                        	0x0033286c (wrapper managed-to-native) MonoTouch.Foundation.NSObject:monotouch_release_managed_ref + 96
18  Mocast                        	0x002dc248 p_224_plt_MonoTouch_Foundation_NSObject_ReleaseManagedRef_llvm + 24
19  Mocast                        	0x002dc028 monotouch__MonoTouch_Foundation_NSObject_Dispose_bool + 88
20  Mocast                        	0x002dbc4c p_77_plt_MonoTouch_Foundation_NSObject_Dispose_llvm + 28
21  Mocast                        	0x00323b60 MonoTouch.UIKit.UITextAttributes:ToDictionary (UITextAttributes.cs:157)
22  Mocast                        	0x002e79c0 monotouch__MonoTouch_UIKit_UINavigationBar_UINavigationBarAppearance_SetTitleTextAttributes_MonoTouch_UIKit_UITextAttributes + 28
23  Mocast                        	0x000d5d10 Mocast.AppDelegate:FinishedLaunching (AppDelegate.cs:142)

=== Xamarin Studio ===

Version 5.1 (build 479)
Installation UUID: e51e2705-c52a-4ae8-aa07-c481d6ab8a7a
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

=== Xamarin.Android ===

Version: 4.12.5 (Enterprise Edition)
Android SDK: /Users/fak/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
Java SDK: /usr
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.Mac ===


=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 87026b6
Build date: 2014-07-02 19:39:08-0400

=== Build Information ===

Release ID: 501000479
Git revision: e5a428cec75d4cc7e6e3ccd8192a3660d013e7dc
Build date: 2014-06-26 09:28:17-04
Xamarin addins: 190d93e026e17280e75a3680ef38f2630b9228d3

=== Operating System ===

Mac OS X 10.9.3
Darwin lepton.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Comment 1 Frank A. Krueger 2014-07-07 15:58:28 UTC
Actually it would seem that I can't compile and run any code now. I keep getting the NRE in `NSObject.ReleaseManagedRef`
Comment 2 Frank A. Krueger 2014-07-07 16:33:11 UTC
Very very strange: I downgraded to 7.2.3, then re-upgraded to and now it runs.
Comment 3 Frank A. Krueger 2014-07-07 18:05:15 UTC
Resolving as Invalid since a re-install fixed it.