Bug 1978 - AppearanceWhenContainedIn throws a NullReferenceException - MT 5.0.2
Summary: AppearanceWhenContainedIn throws a NullReferenceException - MT 5.0.2
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-11-10 03:03 UTC by Dimitris Tavlikos
Modified: 2011-11-10 14:02 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 Dimitris Tavlikos 2011-11-10 03:03:58 UTC
When calling AppearanceWhenContainedIn, a NullReferenceException occurs:

Message: Object reference not set to an instance of an object
StackTrace:   at MonoTouch.UIKit.UIAppearance.GetAppearance (IntPtr class_ptr, System.Type[] whenFoundIn) [0x00068] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIAppearance.cs:59 
  at MonoTouch.UIKit.UISlider.AppearanceWhenContainedIn (System.Type[] containers) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UISlider.g.cs:644 

Steps to reproduce:
1. Create a new Empty iPhone project.
2. Add an iPhone view with controller (I have named it MainController).
3. Open XIB in Xcode and add a UISlider.
4. Connect the UISlider with an outlet.
5. Enter the following code, either in FinishedLaunching or in ViewDidLoad of MainController:

UISlider.UISliderAppearance style = UISlider.AppearanceWhenContainedIn(typeof(MainController)); // throws exception

Also tested the same with a UIButton. Again, an exception is thrown.
Comment 1 Jeffrey Stedfast 2011-11-10 14:02:24 UTC
Fixed in git, should be included in 5.0.3(?)