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.
The NSDecimalNumber ctor NSDecimalNumber(string numberValue), which binds "initWithString:", throws an NRE :
> let n = new NSDecimalNumber("10.0");;
System.NullReferenceException: Object reference not set to an instance of an object
at MonoTouch.ObjCRuntime.Class.Register (System.Type type) [0x00000] in <filename unknown>:0
at MonoTouch.ObjCRuntime.Class.GetHandle (System.Type type) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSObject.AllocIfNeeded () [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSObject..ctor (MonoTouch.Foundation.NSObjectFlag x) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSValue..ctor (MonoTouch.Foundation.NSObjectFlag t) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSNumber..ctor (MonoTouch.Foundation.NSObjectFlag t) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSDecimalNumber..ctor (System.String numberValue) [0x00000] in <filename unknown>:0
at <StartupCode$FSI_0004>.$FSI_0004.main@ () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object,System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Stopped due to error
Wait... Is NSDecimalNumber not supposed to be bound or something?
> let n = NSDecimalNumber.One;;
val n : NSDecimalNumber = null
val it : NSDecimalNumber = null
> let m = NSDecimalNumber.MaxValue;;
val m : NSDecimalNumber = null
> let n = NSDecimalNumber.MinValue;;
val n : NSDecimalNumber = null
This appears to be peculiar to F#, or maybe even the fsharp shell. When executed in a "real" C# program, the constructor and factory methods work.
[[16:14:12] <lobrien> Is MonoTouch.Foundation.NSDecimalNumber not supposed to be bound or something? Neither its constructors nor its factory methods seem to produce objects.
[16:19:44] <spouliot> lobrien: the error is weird, does the same happens from C# ?
[16:20:03] <lobrien> lemme check
[16:20:34] <spouliot> we have test creating every type of NSObject and they do not trigger an error when registering the class
[16:23:54] <lobrien> no
[16:23:59] <lobrien> i mean, no, it works in C#
[16:24:11] <lobrien> That's weird.
[16:24:25] <spouliot> Assert.NotNull (NSDecimalNumber.One, "One");
[16:24:29] <spouliot> ^ works for me
[16:24:46] <spouliot> from where did you run this ? sim, device ?
[16:26:35] <lobrien> I used the fsharp shell. When I just did it in C# it worked fine.
[16:29:28] <spouliot> the shell(s) likely do not initialize anything related to iOS/OSX
[16:30:06] <spouliot> that might be a good feature request (to the shell) but not a bug for XI :)
[16:30:11] <lobrien> yes