I'm trying out XF for MacOS just to get an idea about how well it might work for me in the future. I'm stuck on an issue though just trying to get it to run that I don't know how to work around.
I followed the instructions I found here.
The problem I'm getting is when I call the base.FinishedLoading(notification);
public override void DidFinishLaunching(NSNotification notification)
{
Forms.Init();
LoadApplication(new App());
base.DidFinishLaunching(notification); //exception occurs here.
}
I get a generic object not set to an instance of an object exception. If I comment out that line I don't get an exception but no "Welcome To Xamarin Forms" for my generic base page comes up either. I've tried various versions of the XF from the pre-release that is mentioned into the blog up to the latest pre-release, and latest official release.
I have been able to get the sample project from the blog to work with no problem. Best I can tell is there is some step missing from the blog's instructions.
Stacktrace
at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.UpdateMainMenu () [0x00021] in <95b581f2e57b44db8131a119f4c293d9>:0
at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00047] in <95b581f2e57b44db8131a119f4c293d9>:0
at PackageHubMacOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00013] in /Users/almajensen/Projects/DefaultCollection/_git/ONI.Azure/Package Hub/Test/MobileTester/PackageHubMacOS/AppDelegate.cs:32
at (wrapper managed-to-native) AppKit.NSApplication.NSApplicationMain(int,string[])
at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Library/Frameworks/Xamarin.Mac.framework/Versions/4.2.0.20/src/Xamarin.Mac/AppKit/NSApplication.cs:100
at PackageHubMacOS.MainClass.Main (System.String[] args) [0x00017] in /Users/almajensen/Projects/DefaultCollection/_git/ONI.Azure/Package Hub/Test/MobileTester/PackageHubMacOS/Main.cs:11
Add this prior to Forms.Init();
NSApplication.SharedApplication.MainMenu = new NSMenu();
Yes that would I believe fix it the way the blog describes. I missed looking at the tutorial on xamarin.com which describes a different way instead of having to edit the info.plist as described in the blog there is a checkbox that you can uncheck to stop the mainstoryboard from being the startup storyboard. That's the route I ultimately ended up using to make this work. So I guess really there are 2 different ways to make this work right.
Answers
I'm attaching a blank Xamarin forms app with the added macOS project following the steps from the blog. I'd love to figure out what I'm missing.
Add this prior to Forms.Init();
NSApplication.SharedApplication.MainMenu = new NSMenu();
Yes that would I believe fix it the way the blog describes. I missed looking at the tutorial on xamarin.com which describes a different way instead of having to edit the info.plist as described in the blog there is a checkbox that you can uncheck to stop the mainstoryboard from being the startup storyboard. That's the route I ultimately ended up using to make this work. So I guess really there are 2 different ways to make this work right.
Hello All,
Xamarin.Forms 3.3.0.91... here and the issue still remains, and worse than in previous versions.
I managed to work around it by implementing the tutorial on Xamarin blog and the windows official page last time it happened and it worked (the one I followed for this), but now it's like the issue I had 2 months ago.
Sometimes it starts, sometimes not, and sometimes it even crashes after starting!
To have it start, I remove the Xamain.Forms to put either an old one, or a new depending on what has been installed.
A solution is welcome. Thanks!
N.B: My solution being to erase bin and obj folders, and restore nuget packages, but a long term solution is welcome. Thanks!
Ok, now removing the bin and obj folders, uninstalling and reinstalling the xamarin.forms Nuget, and so forth isn't working anymore.
This is is really annoying.
Why bugs which were present previously pops up a few updates later?