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.
Created attachment 16778 [details]
Xamarin.Mac makes it impossible to build an NSToolbar programmatically, so it seems.
The attached NSWindowController subclass should display a toolbar with one item, but results in an exception:
System.InvalidOperationException: Event registration is overwriting existing delegate. Either just use events or your own delegate: NSToolbarBug.WindowController+ToolbarDelegate AppKit.NSToolbar+_NSToolbarDelegate
at AppKit.NSApplication.EnsureDelegateAssignIsNotOverwritingInternalDelegate (System.Object currentDelegateValue, System.Object newDelegateValue, System.Type internalDelegateType) [0x0004a] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/AppKit/NSApplication.cs:114
at AppKit.NSToolbar.set_WeakDelegate (Foundation.NSObject value) [0x0000e] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/build/mac/mobile/AppKit/NSToolbar.g.cs:566
at AppKit.NSToolbar.set_Delegate (INSToolbarDelegate value) [0x00031] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/build/mac/mobile/AppKit/NSToolbar.g.cs:327
at NSToolbarBug.WindowController.WindowDidLoad () [0x00053] in /Users/aaron/Projects/NSToolbarBug/WindowController.cs:19
at at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string)
at AppKit.NSApplication.Main (System.String args) [0x00041] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/AppKit/NSApplication.cs:94
at NSToolbarBug.MainClass.Main (System.String args) [0x00007] in /Users/aaron/Projects/NSToolbarBug/Main.cs:10
Ah, never mind. The delegate should be providing those default items. By setting the default items directly on the toolbar, I guess the toolbar creates an internal delegate that proxies them.