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.
CRASH @ 03.05.2012 15:33:27
Using UIColor.FromRGB(110, 112, 119) I get the exception below in MT 5.3.3
MONOTOUCH VERSION: 5.3.3
BRAINLOOP MOBILE VERSION: 220.127.116.11503
System.TypeInitializationException: An exception was thrown by the type initializer for BrainloopMobile.UIHelpers ---> System.InvalidCastException: Cannot cast from source type to destination type.
at MonoTouch.UIKit.UIColor.FromRGBA (Single red, Single green, Single blue, Single alpha) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIColor.g.cs:127
at MonoTouch.UIKit.UIColor.FromRGB (Byte red, Byte green, Byte blue) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIColor.cs:25
at MonoTouch.UIKit.UIColor.FromRGB (Int32 red, Int32 green, Int32 blue) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIColor.cs:30
at BrainloopMobile.UIHelpers..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at BrainloopMobile.AppDelegateBase.FinishedLaunching (MonoTouch.UIKit.UIApplication application, MonoTouch.Foundation.NSDictionary launchOptions) [0x000bc] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/AppDelegateBase.cs:662
at BrainloopMobile.AppDelegateIPad.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/AppDelegateIPad.cs:24
at MonoTouch.UIKit.UIApplication.SendEvent (MonoTouch.UIKit.UIEvent uievent) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.g.cs:175
at BrainloopMobile.UIApplicationMain.SendEvent (MonoTouch.UIKit.UIEvent oEvent) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/UIApplicationMain.cs:23
at MonoTouch.UIKit.UIApplication.Main (System.String args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at BrainloopMobile.Application.Main (System.String args) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/Main.cs:15
var c = UIColor.FromRGB (110, 112, 119);
works fine for me. Could it be other values ?
Is this on the simulator or device ?
I'll try to see which values could lead to this.
That exception should occurs only if the generated code returns something that is *not* an UIColor.
Can you attach the full build log (with extra -v -v -v) that provoke this. Some other options might play a role in this. Thanks
I currently cannot upgrade to MT 5.3.3.
But this happened on the device.
It happened in this code:
public static void InitGlobalStyleSettings ()
UIBarButtonItem.Appearance.TintColor = UIHelpers.TINT_COLOR_BAR_BUTTON_ITEM;
UISegmentedControl.Appearance.TintColor = UIHelpers.TINT_COLOR_SEGMENTED_CONTROL;
UISwitch.Appearance.OnTintColor = UIHelpers.TINT_COLOR_SWITCH;
UILabel.Appearance.BackgroundColor = UIColor.Clear;
InitGlobalStyleSettings() gets called from FinishedLaunching.
The color values are statics:
public static UIColor TINT_COLOR_BAR_BUTTON_ITEM = UIColor.FromRGB(102, 112, 119);
public static UIColor TINT_COLOR_SEGMENTED_CONTROL = UIColor.FromRGB(102, 112, 119);
public static UIColor TINT_COLOR_SWITCH = UIColor.FromRGB(102, 112, 119);
do you recall (or still have the same) build options ? (e.g. extra mtouch arguments, GC, LLVM, linker...) if so then it would still b euseful to have a build log
No extra arguments (except the one required to overcome the trampolines problems that you asked to report bugs about in 5.3.3 - i don't remember what they were called).
LLVM on, SGen on, ARM v7 - all other settings default.
I can retry once we have that beast released.
The same code, under the same config, does not fail for me. There's likely something else in your solution that cause this, indirectly, to happen. If you can, please attach a test case (or a subset of the app) that show this and we'll investigate it from there. Thanks!
Created attachment 1922 [details]
This occurs because of --noregistrar. The application cannot somehow (the bug) register monotouch.dll properly. MD application output shows:
2012-05-19 10:05:32.118 GCTest[11345:707] Could not load 'monotouch' for registration. This could be due to an outdated assembly kept by the simulator, location: /private/var/mobile/Applications/39F6D08B-B6F0-4550-9632-CFBD66939765/GCTest.app/monotouch.dll
The bug still exists in 5.3.4 (noregistrar) but the option is not needed anymore (at least for the sample).
Now fixed to provide a better error message:
2012-05-19 10:32:35.661 GCTest[11376:707] Could not load 'monotouch' for registration: System.Exception: Wrapper type 'MonoTouch.UIKit.UIAppearance' is missing its native ObjectiveC class 'UIAppearance'.
at MonoTouch.ObjCRuntime.Class.Register (System.Type type, System.String name, Boolean is_wrapper) [0x006ab] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Class.cs:356
at MonoTouch.ObjCRuntime.Class.Register (System.Type type) [0x0004f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Class.cs:191
at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly a) [0x0009f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:96
^ UIAppearance is a bit of a special case, but its a protocol and was not marked as [Model]. That does not play well with the checks done when --noregistrar was used.
Fixed. Thanks for the test case!
QA: you'll need to copy-paste some existing tests (e.g. this one or any existing samples) and build them using --noregistrar and ensure they work on device.
*** Bug 5139 has been marked as a duplicate of this bug. ***
The "--noregistrar" indeed isn't needed for that sample but it is required to demonstrate the problem. My real app needs the additional option however. But you say the option is gone in future versions of MT?
> The "--noregistrar" indeed isn't needed for that sample
Ok. The fix was tested with both --noregistrar and without it.
> My real app needs the additional option however.
Hopefully that will be fixed too (was there a bug for it?) in the next release.
> you say the option is gone in future versions of MT?
No, sorry if it sounded confusing about "not being needed". To be clear the --noregistrar option is not removed (it's still in 5.3.4).
Is this fixed in 5.99? I'm seeing something similar with UIColor.ColorWithAlpha.
Test case: https://github.com/xamarin/monotouch-samples/tree/monotouch-5.4/CustomPropertyAnimation
And for a feature in my own project it's UIColor.FromCGColor (somewhat based on the above sample), as well as some issues with UIImage.FromFile being called from an Action delegate, which is called from a CALayer.DrawInContext. Unfortunately, I haven't had time create a test case on those (yet).
I should add, that it can happen within a few seconds in the linked test case (both simulator and device - a bit longer on the device for some reason). It happens immediately with my own project.
MT: 5.99.1 (using Xcode 4.5 DP3)
OS: Mountain Lion
Let me know if I should open a separate bug report.