Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I need a way to make a default button not default, and I can find no way to do so with Xam.Mac. This is a blocking issue for our interface right now.
For reference, this code works fine:
var window = NSApplication.SharedApplication.Windows.Handle;
var selector = Selector.GetHandle("setDefaultButtonCell:");
Messaging.IntPtr_objc_msgSend_IntPtr(window, selector, IntPtr.Zero);
I have to ask, given this is not my first "throws when set to null" bug, why the over-aggressive throwing of null ref exceptions?!
@Michael - If you are blocked by an issue and have a business license, as it appears you do, _please_ please use:
instead of filing a raw bug. We use that to fast-lane looking into issues blocking customers like yourself.
To answer your question, this is a binding bug. The objective-c Cocoa API does not give sufficient information to let us know when setting null is allowed or not. We try to catch and test these cases when writing bindings, but we fail-safe to throw by default. This is because catching a C# exception is much more pleasant than an NSException / Native crash.
We'll look at fixing this binding mistake in a future version of Xamarin.Mac, but your work around looks solid until then.
If you wish to turn off the "safety" and remove these thread checks, set the following in your projects:
NSApplication.CheckForIllegalCrossThreadCalls = false;
This will disable all
Would this disable both cross-thread exceptions (which are very useful!) and null red checks?
Ignore that. (It's what I get for trying to reply to bugs without sufficient coffee.) We have a way of disabling null checks, but it is at compile time (on our end) not run time. I misread the code.
It looks like we may have looked into the ability to disable null checks at runtime, but it increased the cost of the checks in the "normal" case (extra static boolean lookup for every single function call that passes params).
Chris, I attempted to convert our app to Xamarin.Mac (Unified). Took some cajoling to get the application to build, but this API snafu is now a much bigger issue because with Unified I no longer have the luxury of dropping down to lower level calls (see https://bugzilla.xamarin.com/show_bug.cgi?id=25847).
Fixed on master / 714ee6b4dd94e029de6d09a83a79c56609b6e391
@ Chris, thanks a lot for sharing the steps to check this issue.
I have checked this issue with the following builds:
=== Xamarin Studio ===
Version 5.9 (build 310)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Mono 4.0.0 ((detached/87c62a1)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400000116
Apple Developer Tools Xcode 6.2 (6776)
Xamarin.Mac Version: 22.214.171.124 (Business Edition)
=== Build Information ===
Release ID: 509000310
Git revision: 5e63e3a7face15bd906106306fb4565eaf503995
Build date: 2015-03-26 12:30:38-04
Xamarin addins: 14cabb8b8f6b94fb7aac79016d64f4b9db4d0091
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
I observed that this issue is working fine. Now, NSWindow.DefaultButtonCell does't throws exception when set to null.
Here is the screencast for the same: http://www.screencast.com/t/4t2jl1GIrm7
This issue has been fixed, hence I am closing this issue.