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.
Version: 220.127.116.11 (Visual Studio Enterprise)
`NSMenu.IndexOfItem(NSObject target, Selector actionSelector)` appears to be bound incorrectly. Apple documentation says that `target` can be `nil`, but if I pass `null` along with any non-null selector, an ArgumentNullException is raised for the `target` parameter.
Try the following in a Mac workbook to reproduce:
NSApplication.SharedApplication.MainMenu.IndexOfItem (null, new ObjCRuntime.Selector("quit:"))
Merged in master https://github.com/xamarin/xamarin-macios/commit/0443d380280ad8a3ba012f51dab0af790ebcf56b
The reason you're getting the NullReferenceException there is because at the point you're trying to call NSApplication.SharedApplication.MainMenu.IndexOfItem in the Main method there, MainMenu is still null (So you're trying to call a method on a null object). If you move your call into the AppDelegate's DidFinishLaunching method, it works fine.