Bug 8641 - TimeZoneInfo.GetSystemTimeZones() throws Null Reference Exception
Summary: TimeZoneInfo.GetSystemTimeZones() throws Null Reference Exception
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2012-11-28 16:32 UTC by Brandon
Modified: 2013-12-05 18:36 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample solution (1.34 MB, application/x-zip-compressed)
2012-11-28 16:32 UTC, Brandon
Details


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 NORESPONSE

Description Brandon 2012-11-28 16:32:53 UTC
Created attachment 3024 [details]
Sample solution

The following line:

			var timezones = TimeZoneInfo.GetSystemTimeZones ();

Throws a null reference exception in even the simplest of MonoTouch projects.

I created a Blank MonoTouch for iPhone project, added this line to app delegates FinishedLaunching(), and it blows up.

This was not happening on MonoTouch 5.2.12.
Comment 1 Sebastien Pouliot 2012-11-28 18:53:30 UTC
Your sample works for me. Can you provide the full version information about your setup ?

You can get them from "MonoDevelop" menu, "About MonoDevelop" item, "Version Information" tab. Click on the "Copy Version Information" button and paste this into this bug report.

Also state which iOS version was used (e.g. device or simulator).
Comment 2 Brandon 2012-11-28 18:54:56 UTC
MonoDevelop 3.0.5
Installation UUID: dfab7a3b-7a24-4063-95ac-10e6885defe3
Runtime:
	Mono 2.10.9 (tarball)
	GTK 2.24.10
	GTK# (2.12.0.0)
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.5.2 (1847)
	 Build 4G2008a
Mono for Android: 4.2.7
Android SDK: /Users/brandon/Downloads/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
Java SDK: /usr
Monotouch: 6.0.6
Build information:
	Release ID: 30005000
	Git revision: e159cf083bd327933166819d94245298898d6e3d
	Build date: 2012-10-24 16:43:06+0000
	Xamarin addins: eea2ed91ae8dd242b281d5ec8f6c2fbc63b4cd3d
Operating System:
	Mac OS X 10.7.5
	Darwin Brandons-MacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2
	    Thu Aug 23 16:25:48 PDT 2012
	    root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
Comment 3 Brandon 2012-11-28 18:55:22 UTC
the iOs version is 6.0 on the Simulator when the issue occurs
Comment 4 Sebastien Pouliot 2012-11-28 19:01:14 UTC
Pretty close to my config (I'm on Montain Lion) where I get 419 items returned.

Can you replace

var timezones = TimeZoneInfo.GetSystemTimeZones ();

with

try {
    var timezones = TimeZoneInfo.GetSystemTimeZones ();
}
catch (Exception e) {
    Console.WriteLine (e);
}


then copy/paste the exception text (from the Application Output pad) into the bug report. Thanks!
Comment 5 Brandon 2012-11-28 20:37:54 UTC
2012-11-28 19:33:39.252 TimeZoneList[3076:21e03] System.NullReferenceException: Object reference not set to an instance of an object
  at MonoTouch.Foundation.NSTimeZone.GetStream (MonoTouch.Foundation.NSTimeZone timeZone) [0x00007] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSTimeZone.cs:17 
  at MonoTouch.Foundation.NSTimeZone._GetData (System.String name) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSTimeZone.cs:28 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000c0] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:234
Comment 6 Sebastien Pouliot 2012-11-29 20:37:32 UTC
I cannot reproduce the issue on Lion (10.7.5) either. However I've seen this stack trace before (a long time ago). 

AFAIK it only happened on Snow Leopard (looks like I was wrong and that Apple did not fix this with Lion) when using the iOS simulator. Sometime the data we asked did not come back or only partially came back. It ndid not happen 100% of the time - but it was pretty consistent on my iMac.

Can you confirm if this only happens on simulator builds ? (and works on devices)

I'll look at handling this error condition in a way that does not stop the application from executing.
Comment 7 Brandon 2012-11-29 21:34:35 UTC
Unfortunately I'm not in a position to continue working on this. As we are on an active project, I have had to roll back to 5.2.12 where this error doesn't occur.

I will keep this bug bookmarked on my end for if/when we move back up to 6.0.6+
Comment 8 Sebastien Pouliot 2012-11-29 21:44:21 UTC
Ok, but you should not go back to a version before 5.2.13 since it has issues wrt iOS6 [1].

[1] http://blog.xamarin.com/2012/08/13/important-ios-6-information-for-monotouch-users/
Comment 9 Peter 2013-06-21 10:39:23 UTC
Has anyone encountered this since, besides me? Interestingly, I am finding the same error on the same line of code listed above (I am new to this project, btw). Same call stack. Any thoughts?
I run on:

=== Xamarin Studio ===

Version 4.0.7 (build 3)
Installation UUID: 80182c68-0771-445c-bf15-ca792523ae8f
Runtime:
	Mono 2.10.12 (mono-2-10/c9b270d)
	GTK 2.24.16
	GTK# (2.12.0.0)
	Package version: 210120000

=== Apple Developer Tools ===

Xcode 4.5.1 (1842)
Build 4G1004

=== Xamarin.iOS ===

Version: 6.2.7.1 (Enterprise Edition)
Hash: 947e664
Branch: 
Build date: 2013-30-05 18:02:40-0400

=== Build Information ===

Release ID: 400070003
Git revision: 0f1da1e7f83345a52a4b68b8142ce699a6b2ada0
Build date: 2013-05-15 19:42:15+0000
Xamarin addins: 9d3dcd5b80ef94f6d91065e914c053a708c5e65b

=== Operating System ===

Mac OS X 10.7.5
Darwin Peters-MacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2
    Thu Aug 23 16:25:48 PDT 2012
    root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
Comment 10 PJ 2013-11-19 17:06:03 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 11 PJ 2013-12-05 18:36:32 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.