Bug 12763 - View property of NSStatusItem instance doesn't accept NULL
Summary: View property of NSStatusItem instance doesn't accept NULL
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.12.0
Hardware: All Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
Depends on:
Reported: 2013-06-19 09:41 UTC by Nikolay Ivanets
Modified: 2015-03-05 03:56 UTC (History)
4 users (show)

Tags: NSStatusItem
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 Nikolay Ivanets 2013-06-19 09:41:22 UTC
I get ArgumentNullException when I try to execute the following code:

NSStatusItem _statusItem = ...; // Create status item
_statusItem.View = null;

What I get from Assembly Browser:

	if (value == null)
		throw new ArgumentNullException("value");

However, nil is valid value for setView: message in Objective-C.

For now I use a workaround which allow me to set null for View:

// MONO bug: cannot set NULL for View. Let's use native call
//_statusItem.View = null;
var sel = new Selector("setView:");
Messaging.void_objc_msgSend_IntPtr(_statusItem.Handle, sel.Handle, IntPtr.Zero);
Comment 1 Timothy Risi 2015-02-20 21:42:00 UTC
Fixed on master / 714ee6b4dd94e029de6d09a83a79c56609b6e391
Comment 2 Rajneesh Kumar 2015-03-05 02:37:38 UTC
To verify this issue I try to reproduce this but not sure about the steps, that how to check this issue. Could you please share the steps to check this issue? That will be very helpful to verify this issue efficiently.

However I am not able to see the the following line of code in assembly browser:
    if (value == null)
        throw new ArgumentNullException("value");

Screencast: http://www.screencast.com/t/kJyToI4y8o

Comment 3 Nikolay Ivanets 2015-03-05 03:31:57 UTC
Here is a code to reproduce:

NSStatusItem _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusBar.SystemStatusBar.Thickness);
_statusItem.View = null;
Comment 4 Rajneesh Kumar 2015-03-05 03:56:31 UTC
@Nikolay, Thanks a lot for providing the code to check this issue. I have checked this issue with the following build:

=== Xamarin Studio ===
Version 5.9 (build 120)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Mono 4.0.0 ((detached/51d34c6)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400000028
 Apple Developer Tools Xcode 6.2 (6770)
Build 6C121
Xamarin.Mac  Version: (Business Edition)
=== Build Information ===
Release ID: 509000120
Git revision: f5e41538f5c8635b6c00fb22f522c1de4f6509b0
Build date: 2015-03-03 17:56:32-05
Xamarin addins: 564d7bb0d7d0bc4440c14e7baf16db2fadb76975
Operating System Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

This issue is working fine. Now View property of NSStatusItem instance accept NULL. Here is the screencast for the same: http://www.screencast.com/t/zirmLhvxO80w

This issue has been fixed hence I am closing this issue.