Bug 29811 - Exception thrown by NSDate.FromTimeIntervalSinceNow()
Summary: Exception thrown by NSDate.FromTimeIntervalSinceNow()
Status: RESOLVED DUPLICATE of bug 29801
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-06 15:29 UTC by Randall Schmidt
Modified: 2015-05-11 13:34 UTC (History)
4 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 DUPLICATE of bug 29801

Description Randall Schmidt 2015-05-06 15:29:06 UTC
After upgrading from the stable channel on 5/6 and upgrading Xcode from 6.2 to 6.3 we have begun periodically seeing the following exception thrown from NSDate.FromTimeIntervalSinceNow:

System.InvalidCastException: Unable to cast object of type 'Foundation.NSAsyncActionDispatcher' to type 'Foundation.NSDate'

  at ObjCRuntime.Runtime.GetNSObject[NSDate] (IntPtr ptr) [0x00000] in <filename unknown>:0 
  at Foundation.NSDate.FromTimeIntervalSinceNow (Double secs) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/build/ios/native/Foundation/NSDate.g.cs:139 
  <Our Code>

If I put the code that creates the NSDate object into a try catch and just retry if an exception is thrown, then it succeeds the second time around.

The code runs in a background thread after the OnResignActivation() handler is called. Unfortunately I haven't had any luck reproducing it in a test case. Our app does a lot of things in a dozen-ish threads in response to resigning activation and I suspect it has something to do with threading.
Comment 1 Sebastien Pouliot 2015-05-06 17:04:33 UTC
There's another similar bug report that just got in. Can you tell us the exact version you're using* and what was the previous version you were using (without the issue) ?


* The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 Randall Schmidt 2015-05-06 17:13:19 UTC
Previously we were using:

X.iOS 8.8.1.9
Xcode 6.2 (6776)
Mono 3.12.1 ((detached/b7764aa)
GTK+ 2.24.23 (Raleigh theme)

Now I am using:
X.iOS 8.10.0.267 (Business Edition)
Xcode 6.3.1 (7703)
Mono 4.0.0 ((detached/d136b79)
GTK+ 2.24.23 (Raleigh theme)



Complete About Xamarin Studio info with the bug occuring:


Xamarin Studio
Version 5.9 (build 431)
Installation UUID: 76cd4550-0ba3-46c2-9700-950d32dbe636
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

Xamarin.Android
Not Installed

Xamarin Android Player
Not Installed

Apple Developer Tools
Xcode 6.3.1 (7703)
Build 6D1002

Xamarin.Mac
Not Installed

Xamarin.iOS
Version: 8.10.0.267 (Business Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

Build Information
Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

Operating System
Mac OS X 10.10.3
Darwin machine_name 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64





Without the bug occuring:


Xamarin Studio
Version 5.8.1 (build 
Installation UUID: 46f21a4c-83b1-49b9-99e1-f7cdaf62ea56
Runtime:
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Xamarin.iOS
Version: 8.8.1.9 (Business Edition)
Hash: 7e1f69e
Branch: 
Build date: 2015-03-12 15:35:49-0400

Xamarin.Android
Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/ecasas/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)
		4.4    (API level 19)
		4.4.87 (API level 20)
Java SDK: /usr
No Java runtime present, requesting install.

Xamarin Android Player
Not Installed

Xamarin.Mac
Not Installed

Build Information
Release ID: 508010008
Git revision: f8e52bf493869b6a320a95400553dc9ea8b7ef22
Build date: 2015-03-13 16:16:49-04
Xamarin addins: 84d611cc17567a68daad719327e90af06d2ae327

Operating System
Mac OS X 10.10.3
Darwin machine_name 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-05-11 13:34:06 UTC
This is probably a dup of #29801.

*** This bug has been marked as a duplicate of bug 29801 ***