Bug 13792 - Trying to use Content property of NSTreeController causes InvalidCastException
Summary: Trying to use Content property of NSTreeController causes InvalidCastException
Status: RESOLVED FIXED
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-08-06 19:47 UTC by David Lechner
Modified: 2014-06-19 21:07 UTC (History)
3 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 FIXED

Description David Lechner 2013-08-06 19:47:31 UTC
For some reason, the Content property of NSTreeController is typed as NSTreeController. From apple's docs, it looks like it should just be NSObject[1]. As a result, if you try to use this property, you get an InvalidCastException.

I could not come up with a simple sample to reproduce the error, but if needed, I could make a small project and attach it to the bug.



[1] <https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTreeController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTreeController/setContent:>
Comment 1 Miguel de Icaza [MSFT] 2014-02-11 23:29:05 UTC
Thanks!

Fixed
Comment 2 xamarin 2014-06-19 21:07:33 UTC
The most recent stable installers (as of June 18, 2014) still have this problem for NSTreeController (at least in MonoMac).

As an easy workaround, cast to NSObjectController, then access its Content property instead.