Bug 14203 - NSFetchedResultsController.Sections throws an exception System.InvalidCastException
Summary: NSFetchedResultsController.Sections throws an exception System.InvalidCastExc...
Status: RESOLVED DUPLICATE of bug 13785
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: 6.4.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-08-23 05:28 UTC by Prashant Cholachagudda
Modified: 2013-08-24 10:34 UTC (History)
3 users (show)

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

Test case (20.56 KB, application/zip)
2013-08-23 05:29 UTC, Prashant Cholachagudda

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 Prashant Cholachagudda 2013-08-23 05:28:58 UTC
After calling PerformFetch successfully, trying to access the Sections property
results in InvalidCastException.  

System.InvalidCastException: Cannot cast from source type to destination type.

at at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)

at MonoTouch.Foundation.NSArray.ArrayFromHandle[NSFetchedResultsSectionInfo] (IntPtr handle) [0x00044] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:188

at MonoTouch.CoreData.NSFetchedResultsController.get_Sections () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/CoreData/NSFetchedResultsController.g.cs:354

at CoreData.TableViewSource.RowsInSection (MonoTouch.UIKit.UITableView tableView, Int32 section) [0x00007] in /Users/g/Projects/CoreData/CoreData/DataEnvironment.cs:204

at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)

at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:129

at CoreData.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00038] in /Users/g/Projects/CoreData/CoreData/AppDelegate.cs:31

at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)

at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38

at CoreData.Application.Main (System.String[] args) [0x00008] in /Users/g/Projects/CoreData/CoreData/Main.cs:16
Comment 1 Prashant Cholachagudda 2013-08-23 05:29:50 UTC
Created attachment 4699 [details]
Test case
Comment 3 Sebastien Pouliot 2013-08-24 10:34:43 UTC
It's fixed in Xamarin.iOS 6.9.x but the fix is not related to iOS7 (comment #2). IOW the Xamarin.iOS 7.0 stable release (which will include this fix) will work on older iOS releases.

This is fixed by how protocols are supported by the binding generator (i.e. btouch). This is a big change and won't be backported to the stable 6.4 release (which is why the fix is only avaiable in 6.9+).

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