Bug 2583 - Issue while calling UIFont.SystemFontOfSize()
Summary: Issue while calling UIFont.SystemFontOfSize()
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-12-20 14:05 UTC by Jon Lipsky
Modified: 2012-01-16 17:18 UTC (History)
2 users (show)

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:

Description Jon Lipsky 2011-12-20 14:05:43 UTC

The new version of TouchDraw was compiled using MonoTouch 5.0.4.  In the day and a half that this version has been released, I've already received a few crash reports due to the following exception:

System.Exception: Selector invoked from objective-c on a managed object that has been GC'ed ---> System.MissingMethodException: No constructor found for MonoTouch.Foundation.NSActionDispatcher::.ctor(System.IntPtr)
  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0 
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x00000] in <filename unknown>:0 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in <filename unknown>:0 
  at MonoTouch.UIKit.UIFont.SystemFontOfSize (Single size) [0x00000] in <filename unknown>:0 
  at Elevenworks.MonoTouch.Views.MTStrokeView.InitializeSubViews (RectangleF aRect) [0x00000] in <filename unknown>:0 
  at Elevenworks.MonoTouch.Views.MTStrokeView.InitializeSubViews (RectangleF aRect) [0x00000] in <filename unknown>:0 
  at Elevenworks.MonoTouch.Views.MTLayoutView.Initialize (System.String aLayout, RectangleF aRect) [0x00000] in <filename unknown>:0 
  at Elevenworks.MonoTouch.Views.MTLayoutView..ctor (System.String aLayout, RectangleF aRect, MonoTouch.UIKit.UIViewController aController) [0x00000] in <filename unknown>:0 
  at Elevenworks.MonoTouch.Views.MTStrokeView..ctor (RectangleF aRect, Elevenworks.MonoTouch.Views.MTStrokeViewController aController) [0x00000] in <filename unknown>:0 

I can't reproduce this issue on any of my devices, nor have any of our beta testers run into this; however the problem seems to be in MonoTouch, and not within any of my code.

Comment 1 Jon Lipsky 2011-12-21 08:27:21 UTC
Overnight, I got a few more error reports from users where they encountered a different exception within that same method:

System.InvalidCastException: Cannot cast from source type to destination type.
  at MonoTouch.UIKit.UIFont.SystemFontOfSize (Single size) [0x00000] in <filename unknown>:0 

Is this related to the issue above?

Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-01-16 07:50:07 UTC
This error doesn't make much sense really (for instance SystemFontOfSize is documented to only return UIFonts, so why would it return a NSActionDispatcher?), and our related code looks quite right.

Do you have sample code where this is happening? Without it I doubt it will be possible to find the issue.
Comment 3 Jon Lipsky 2012-01-16 10:31:46 UTC
Hi Rolf,

I agree that it doesn't make much sense.

I don't have any sample code that can reproduce it, nor have I been able to reproduce it myself.  I just found out about this error through the error reports (stack traces) that I have users submit to me if an unexpected error occurs in TouchDraw.

I can tell you that this happened when TouchDraw was compiled with MonoTouch 5.0.4, and since when I released the last update to TouchDraw with MonoTouch 5.0.3 (I downgraded), these errors went away.

I realize you probably can't do anything; however I thought I should at least submit the bug report.

Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-01-16 17:18:16 UTC
I just checked everything that changed between 5.0.3 and 5.0.4, and there is nothing even remotely related to UIFont nor SystemFontOfSize.

I'll close this bug report then, but don't hesitate to reopen if the issue comes back at a later point.