Bug 24360 - Xamarin Mac F# Project: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
Summary: Xamarin Mac F# Project: Unhandled Exception: System.NullReferenceException: O...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: Master
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Dave Thomas
URL:
Depends on:
Blocks:
 
Reported: 2014-11-07 23:27 UTC by Babu Srinivasan
Modified: 2014-11-24 03:23 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

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 Babu Srinivasan 2014-11-07 23:27:23 UTC
I selected a new-solution and Xamarin Mac Project (F#), 
Build All ==> Says 0 errors, 7 warnings.
Click on play to run app and I get

Loaded assembly: /Users/babu/Projects/xam/KeyMac/KeyMac/bin/Debug/KeyMac.app/Contents/MonoBundle/KeyMac.exe
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/gac/FSharp.Core/4.3.1.0__b03f5f7f11d50a3a/FSharp.Core.dll [External]
Loaded assembly: /Users/babu/Projects/xam/KeyMac/KeyMac/bin/Debug/KeyMac.app/Contents/MonoBundle/XamMac.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll [External]
Loaded assembly: ObjCImplementations [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll [External]

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at KeyMac.AppDelegate.FinishedLaunching (MonoMac.Foundation.NSObject) [0x00007] in /Users/babu/Projects/xam/KeyMac/KeyMac/AppDelegate.fs:16
at (wrapper dynamic-method) object.[KeyMac.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x00011, 0x00062>
at (wrapper native-to-managed) object.[KeyMac.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x0006c, 0x00183>
at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>
at MonoMac.AppKit.NSApplication.Main (string[]) [0x00041] in /Users/builder/data/lanes/xamcore-lion-1.10-branch/2ff3e7b7/source/xamcore/src/AppKit/NSApplication.cs:105
at KeyMac.main.main (string[]) [0x00006] in /Users/babu/Projects/xam/KeyMac/KeyMac/AppDelegate.fs:22

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at KeyMac.AppDelegate.FinishedLaunching (MonoMac.Foundation.NSObject) [0x00007] in /Users/babu/Projects/xam/KeyMac/KeyMac/AppDelegate.fs:16
at (wrapper dynamic-method) object.[KeyMac.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x00011, 0x00062>
at (wrapper native-to-managed) object.[KeyMac.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x0006c, 0x00183>
at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>
at MonoMac.AppKit.NSApplication.Main (string[]) [0x00041] in /Users/builder/data/lanes/xamcore-lion-1.10-branch/2ff3e7b7/source/xamcore/src/AppKit/NSApplication.cs:105
at KeyMac.main.main (string[]) [0x00006] in /Users/babu/Projects/xam/KeyMac/KeyMac/AppDelegate.fs:22
Comment 1 Shruti 2014-11-10 02:43:28 UTC
I have checked this issue and able to reproduce it. I have created a Xam Mac project in F#. Build it and then Run this project and get Exception of 'System.NullReferenceException'.

Screencast : http://screencast.com/t/H63z79Bu
Application Output : https://gist.github.com/Shruti360/92803a73975f191992cf

Environment Info :

=== Xamarin Studio ===

Version 5.7 (build 404)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
Runtime:
	Mono 3.10.0 ((detached/fe854ad)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000025

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.2.0.57 (Business Edition)
Hash: 06491f3
Branch: 
Build date: 2014-09-06 14:03:16-0400

=== Xamarin.Android ===

Version: 4.18.1.3 (Business Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.1.3 (Business Edition)

=== Build Information ===

Release ID: 507000404
Git revision: 74d83538735a774196dc3071efb6cedf418aa850
Build date: 2014-11-05 07:53:14-05

=== Operating System ===

Mac OS X 10.9.4
Darwin XamnewiMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 Chris Hamons 2014-11-10 11:54:48 UTC
This is supposed to be fixed in:

https://bugzilla.xamarin.com/show_bug.cgi?id=22110

But is not. Assigning to Dave as was pointed to by Miguel in ETL.
Comment 3 Dave Thomas 2014-11-11 04:13:14 UTC
I cant replicate this.

=== Xamarin Studio ===

Version 5.6.2 (build 5)
Installation UUID: 86064031-f311-4b4b-9bd7-3e7bbf0f19b8
Runtime:
	Mono 3.10.0 ((detached/633e444)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000020

=== Apple Developer Tools ===

Xcode 6.0 (6299)
Build 6A313

=== Xamarin.iOS ===

Version: 8.2.0.193 (Business Edition)
Hash: 959c1e4
Branch: 
Build date: 2014-10-03 00:25:37-0400

=== Xamarin.Android ===

Version: 4.99.0 (Business Edition)
Android SDK: /Users/dave/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.0    (API level 11)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.1.3 (Business Edition)

=== Build Information ===

Release ID: 506020005
Git revision: 19bc3b64b70332bfab18faf9cf1ce7d3aa191b36
Build date: 2014-10-17 14:49:01-04

=== Operating System ===

Mac OS X 10.10.0
Darwin Daves-MacBook-Pro-9.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 4 Dave Thomas 2014-11-11 04:18:50 UTC
Nothing has changed in F# Xamarin.Mac project templates since April this year, any regression is likely to be caused by Xamarin.Mac, although I cant reproduce this at all.
Comment 5 Babu Srinivasan 2014-11-22 03:25:46 UTC
Any update on this bug?
I am now using Xamarin Studi 5.5.4 (build 15)
Still broken. I can't create a simple F# Xamarin.Mac Project and start writing F# code.
Is F# on Xamarin.Mac an unsupported product?

Miguel has asked us to test the future of xamarin.mac
http://blog.xamarin.com/help-test-the-future-of-xamarin.mac/

But present basic fucntionality is not working and I can't switch to F# from C#.
Comment 6 Dave Thomas 2014-11-24 03:23:42 UTC
This was a regression in F# codedom support and was fixed in fsharpbinding master, which should appear in the next release to the alpha channel.   

It can also be fixed manually by adding the missing constructor which was not generated automatically in the MainWindowController:

new() = { inherit NSWindowController("MainWindow") }