Bug 60370 - [Mac] Nightly crashes on NRE after LoadApplication in DidFinishLaunching
Summary: [Mac] Nightly crashes on NRE after LoadApplication in DidFinishLaunching
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Mac ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2017-10-25 14:54 UTC by David Ortinau [MSFT]
Modified: 2018-04-16 07:13 UTC (History)
7 users (show)

Tags: ac, mac, nightly, nre, fr
Is this bug a regression?: ---
Last known good build:


Attachments
sample project (353.07 KB, application/zip)
2017-10-25 14:54 UTC, David Ortinau [MSFT]
Details


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 Ortinau [MSFT] 2017-10-25 14:54:23 UTC
Created attachment 25446 [details]
sample project

2.5.1.31717-nightly
macOS 10.13

Environment: https://gist.github.com/davidortinau/6e10a6844b48fc6df03a82e3bc31ff30

Run the app and it crashes immediately on launch. Project attached.

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.UpdateMainMenu () [0x00029] in <cbe6fd9a995b41eaa277714bfd1de464>:0 
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00055] in <cbe6fd9a995b41eaa277714bfd1de464>:0 
  at NightlyMac.macOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00013] in /Users/dave/Projects/NightlyMac/NightlyMac.macOS/AppDelegate.cs:33 
  at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
  at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/5143/09806627/source/xamarin-macios/src/AppKit/NSApplication.cs:100 
  at NightlyMac.macOS.MainClass.Main (System.String[] args) [0x00017] in /Users/dave/Projects/NightlyMac/NightlyMac.macOS/Main.cs:11 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.UpdateMainMenu () [0x00029] in <cbe6fd9a995b41eaa277714bfd1de464>:0 
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00055] in <cbe6fd9a995b41eaa277714bfd1de464>:0 
  at NightlyMac.macOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00013] in /Users/dave/Projects/NightlyMac/NightlyMac.macOS/AppDelegate.cs:33 
  at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
  at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/5143/09806627/source/xamarin-macios/src/AppKit/NSApplication.cs:100 
  at NightlyMac.macOS.MainClass.Main (System.String[] args) [0x00017] in /Users/dave/Projects/NightlyMac/NightlyMac.macOS/Main.cs:11
Comment 1 Michael 2017-11-29 17:01:27 UTC
Rolling back to 2.4.0.91020 is a temporary work around
Comment 2 David Ortinau [MSFT] 2017-12-04 20:36:24 UTC
Tested on 2.5.1.102606-nightly and this is fixed.
Comment 3 YFerrando 2017-12-12 15:26:00 UTC
NSApplication.SharedApplication.MainMenu = new NSMenu(); fix the issue on 2.5.0.121934
Comment 4 Samantha Houts [MSFT] 2017-12-22 03:18:18 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1246
Comment 5 christian.kapplmueller 2018-04-16 06:44:13 UTC
Seems to be still a issue in 2.5.1.444934. I also used the workaround @YFerrando provided (assigning SharedApplication.MainMenu). Has anyone an update on this?
Comment 6 christian.kapplmueller 2018-04-16 07:13:10 UTC
Just found out that https://blog.xamarin.com/preview-bringing-macos-to-xamarin-forms/ is outdated, because is instructs you to remove NSMainStoryboardFile from Info.plist. The instructions in https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/mac work like a charm.

Maybe it should be considered to deprecate/update the blog entry.