xamarin.forms ios app starts crashing randomly - ios

after last update our app start crashing randomly on some user devices . i can't get this crash on my ipad in release version, so may be it is device specific or ios version specific.
crash seems to be google ads related.
while i am trying to find a reason , may be somebody has an idea where to dig
thanks in advance. below info from appcentre.ms . it's from app main crash ,but crash happens in different places
pplication.Main (System.String[] args)
SIGABRT: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Can't add self as subview Native stack trace: 0 CoreFoundation 0x000000019ad74604 409609CD-8410-38E1-BA5D-BDED609D2018 + 1222148 1 libobjc.A.dylib 0x000000019aa96bcc objc_exception_throw + 56 2 CoreFoundation 0x000000019ac6ab28 409609CD-8410-38E1-BA5D-BDED609D2018 + 133928 3 UIKitCore 0x000000019f2c6c54 3062FF32-2182-37A2-A5F9-B38F6FB6B8C3 + 15547476 4 MyApp.iOS 0x00000001035e1108 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 18464880 5 MyApp.iOS 0x000000010355ba94 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 17918460 6 MyApp.iOS 0x0000000103781720 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20170376 7 MyApp.iOS 0x00000001037654d8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20055104 8 MyApp.iOS 0x0000000103764a20 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20052360 9 MyApp.iOS 0x0000000103760c60 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20036552 10 MyApp.iOS 0x0000000103760354 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20034236 11 MyApp.iOS 0x0000000103763d24 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20049036 12 MyApp.iOS 0x0000000103763a30 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20048280 13 MyApp.iOS 0x0000000103765938 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20056224 14 MyApp.iOS 0x00000001037654d8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20055104 15 MyApp.iOS 0x0000000103764a20 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20052360 16 MyApp.iOS 0x0000000103760c60 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20036552 17 MyApp.iOS 0x0000000103760354 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20034236 18 MyApp.iOS 0x0000000103763d24 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20049036 19 MyApp.iOS 0x0000000103763a30 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20048280 20 MyApp.iOS 0x0000000103765938 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20056224 21 MyApp.iOS 0x00000001037654d8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20055104 22 MyApp.iOS 0x0000000103764a20 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20052360 23 MyApp.iOS 0x000000010376f548 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20096176 24 MyApp.iOS 0x000000010376e4b0 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20091928 25 MyApp.iOS 0x000000010376e328 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20091536 26 MyApp.iOS 0x00000001050f8e8c GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 46874100 27 MyApp.iOS 0x000000010376a5cc GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20075828 28 MyApp.iOS 0x000000010378f6f4 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 20227676 29 MyApp.iOS 0x00000001028acc20 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 4619144 30 MyApp.iOS 0x00000001055382a8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 51327504 31 MyApp.iOS 0x00000001055f3784 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 52094700 32 MyApp.iOS 0x00000001055f6fe8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 52109136 33 MyApp.iOS 0x00000001024e523c GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 655780 34 MyApp.iOS 0x00000001024fb474 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 746460 35 UIKitCore 0x000000019f0138b0 3062FF32-2182-37A2-A5F9-B38F6FB6B8C3 + 12716208 36 UIKitCore 0x000000019efe1640 3062FF32-2182-37A2-A5F9-B38F6FB6B8C3 + 12510784 37 UIKitCore 0x000000019effe364 3062FF32-2182-37A2-A5F9-B38F6FB6B8C3 + 12628836 38 UIKitCore 0x000000019f2cdc7c 3062FF32-2182-37A2-A5F9-B38F6FB6B8C3 + 15576188 39 QuartzCore 0x00000001a18674ac BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 1381548 40 QuartzCore 0x00000001a186d604 BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 1406468 41 QuartzCore 0x00000001a1878148 BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 1450312 42 QuartzCore 0x00000001a17c0e34 BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 699956 43 QuartzCore 0x00000001a17ea7c4 BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 870340 44 QuartzCore 0x00000001a17eb1d8 BA9ECCEE-9F61-3BAA-B8A8-8EB3B7E0A24F + 872920 45 CoreFoundation 0x000000019acf1fb8 409609CD-8410-38E1-BA5D-BDED609D2018 + 688056 46 CoreFoundation 0x000000019aceceac 409609CD-8410-38E1-BA5D-BDED609D2018 + 667308 47 CoreFoundation 0x000000019aced328 409609CD-8410-38E1-BA5D-BDED609D2018 + 668456 48 CoreFoundation 0x000000019acecc34 CFRunLoopRunSpecific + 424 49 GraphicsServices 0x00000001a4e3638c GSEventRunModal + 160 50 UIKitCore 0x000000019ee1f22c UIApplicationMain + 1932 51 MyApp.iOS 0x00000001035fc2c8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 18575920 52 MyApp.iOS 0x00000001035380b0 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 17772568 53 MyApp.iOS 0x0000000103538034 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 17772444 54 MyApp.iOS 0x0000000102526ed4 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 925244 55 MyApp.iOS 0x00000001028acc20 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 4619144 56 MyApp.iOS 0x00000001055382a8 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 51327504 57 MyApp.iOS 0x00000001055f3784 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 52094700 58 MyApp.iOS 0x00000001055f99dc GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 52119876 59 MyApp.iOS 0x0000000105516860 GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 51189704 60 MyApp.iOS 0x00000001056d3664 xamarin_release_block_on_main_thread + 27000 61 MyApp.iOS 0x0000000102526a9c GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth + 924164 62 libdyld.dylib 0x000000019ab74800 876FB49A-BFBA-37BF-AD37-6FFC90F7F981 + 6144 
Stack traces
Runtime.ThrowNSException (System.IntPtr ns_exception)
Runtime.throw_ns_exception (System.IntPtr exc)
(wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr)
UIView.AddSubview (UIKit.UIView view)
FrameRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement)
RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement)
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
VisualElementPackager.OnRendererElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs args)
VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement)
RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement)
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
VisualElementPackager.OnRendererElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs args)
VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
ViewCellRenderer+ViewTableCell.UpdateCell (Xamarin.Forms.ViewCell cell)
ViewCellRenderer+ViewTableCell.set_ViewCell (Xamarin.Forms.ViewCell value)
ViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
XFGlossViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
CellTableViewCell.GetNativeCell (UIKit.UITableView tableView, Xamarin.Forms.Cell cell, System.Boolean recycleCells, System.String templateId)
ListViewRenderer+ListViewDataSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath)
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr)
UIView.AddSubview (UIKit.UIView view)
FrameRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement)
RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement)
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
VisualElementPackager.OnRendererElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs args)
VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement)
RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement)
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
VisualElementPackager.OnRendererElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs args)
VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
VisualElementRenderer`1[TElement].SetElement (TElement element)
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
ViewCellRenderer+ViewTableCell.UpdateCell (Xamarin.Forms.ViewCell cell)
ViewCellRenderer+ViewTableCell.set_ViewCell (Xamarin.Forms.ViewCell value)
ViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
XFGlossViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
CellTableViewCell.GetNativeCell (UIKit.UITableView tableView, Xamarin.Forms.Cell cell, System.Boolean recycleCells, System.String templateId)
ListViewRenderer+ListViewDataSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath)
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

well, it turns out i am not the only one
https://github.com/xamarin/Xamarin.Forms/issues/11183
seems to be a bug in listview.
downgrade to Xamarin.Forms version 4.6.0.847 will solve this problem

Related

Xamarin-iOS crash: Since iOS 13 our app has been crashing whenever voice over is turned on

I've been able te reproduce it while using the Xcode accessibility inspector.
The concerning page holds numerous UI elements which used to work fine with voice over.
I've been looking all over the internet but up to now it feels like we're the only one with this problem.
`Foundation.MonoTouchException: Objective-C exception thrown. Name: NSRangeException Reason: NSConcreteAttributedString attributedSubstringFromRange:: Out of bounds
Native stack trace:
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512539b2 objc_exception_throw + 48
2 Foundation 0x00007fff25a0dfb6 -[NSAttributedString attributedSubstringFromRange:replacingCharactersInRanges:numberOfRanges:withString:] + 0
3 UIKit 0x000000011a6595c2 __58-[UITextViewAccessibility _accessibilityParagraphElements]_block_invoke + 216
4 Foundation 0x00007fff25966dc3 -[NSString enumerateSubstringsInRange:options:usingBlock:] + 2104
5 UIKit 0x000000011a6593e9 -[UITextViewAccessibility _accessibilityParagraphElements] + 436
6 UIKit 0x000000011a6577a8 -[UITextViewAccessibility accessibilityElements] + 45
7 UIAccessibility 0x00007fff486f8d9a -[NSObject(AXPrivCategory) _accessibilityElements] + 69
8 UIAccessibility 0x00007fff4871b602 -[NSObjectAccessibility accessibilityElementCount] + 81
9 UIAccessibility 0x00007fff486f8821 -[NSObject(AXPrivCategory) _accessibilityHasOrderedChildren] + 46
10 UIAccessibility 0x00007fff486ef186 -[UIView(UIAccessibilityElementTraversal) _accessibilityShouldBeAddedToViewChildrenWithOptions:] + 214
11 UIAccessibility 0x00007fff486efabb -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 164
12 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
13 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
14 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
15 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
16 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
17 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
18 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
19 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
20 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
21 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
22 UIAccessibility 0x00007fff486eff45 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 1326
23 UIAccessibility 0x00007fff486f03de +[UIView(UIAccessibilityElementTraversal) _accessibilityElementsAndContainersDescendingFromViews:options:sorted:] + 507
24 UIAccessibility 0x00007fff486f0b2d -[UIApplication(UIAccessibilityElementTraversal) _accessibilityViewChildrenWithOptions:referenceWindow:] + 561
25 UIKit 0x000000011a618588 -[UIApplicationAccessibility _accessibilityElementFirst:last:forFocus:allowScrolling:] + 206
26 UIKit 0x000000011a61cb2a -[UIApplicationAccessibility _iosAccessibilityAttributeValue:] + 728
27 UIAccessibility 0x00007fff486e40da _copyAttributeValueCallback + 432
28 AXRuntime 0x00007fff2e735816 ___AXXMIGCopyAttributeValue_block_invoke + 46
29 AXRuntime 0x00007fff2e7356e3 _handleNonMainThreadCallback + 55
30 AXRuntime 0x00007fff2e7355a6 _AXXMIGCopyAttributeValue + 286
31 AXRuntime 0x00007fff2e72e0f3 _XCopyAttributeValue + 269
32 AXRuntime 0x00007fff2e745ba6 mshMIGPerform + 237
33 CoreFoundation 0x00007fff23da2449 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 41
34 CoreFoundation 0x00007fff23da1a48 __CFRunLoopDoSource1 + 472
35 CoreFoundation 0x00007fff23d9c474 __CFRunLoopRun + 2228
36 CoreFoundation 0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
37 GraphicsServices 0x00007fff38c39bbe GSEventRunModal + 139
38 UIKitCore 0x00007fff49325968 UIApplicationMain + 1605
39 ??? 0x0000000109b53095 0x0 + 4457836693
40 ??? 0x0000000109b52de3 0x0 + 4457836003
41 ??? 0x00000001093c69f3 0x0 + 4449921523
42 Mono 0x0000000103204641 mono_jit_runtime_invoke + 1569
43 Mono 0x00000001033f8cd8 mono_runtime_invoke_checked + 136
44 Mono 0x00000001033ff045 mono_runtime_exec_main_checked + 117
45 Mono 0x000000010325f16c mono_jit_exec + 364
46 MHMobileAppsNewsAppiOS 0x0000000102c958cd xamarin_main + 2685
47 MHMobileAppsNewsAppiOS 0x0000000102c52237 main + 71
48 libdyld.dylib 0x00007fff520ce1fd start + 1
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:406
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:128
at at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at MH.MobileApps.NewsApp.iOS.Application.Main (System.String[] args) [0x0001c] in /Users/erland/Projects/Mediahuis/projects/NewsApp/NewsApp.iOS/Main.cs:15`

Xamarin iOS crash on startup after migrating from MvvmCross 4 to 5

After upgrading MvvmCross from version 4 to 5.1.1, I get the a TargetInvocationException at my entrypoint (UIApplication.Main(...)). This is the class:
using UIKit;
namespace sample
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
}
And this is the exception that is thrown:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
2017-10-25 11:12:34.931 SampleAppMobileiOS[5351:568000]
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at MvvmCross.Platform.Mvx.Resolve[TService] () [0x00006] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.iOS.Views.MvxBindingViewControllerAdapter.HandleViewDidDisappearCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1[T] e) [0x00029] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxBindingViewControllerAdapter.cs:26
at MvvmCross.iOS.Views.MvxViewControllerAdaptingExtensions.AdaptForBinding (MvvmCross.Platform.iOS.Views.IMvxEventSourceViewController view) [0x00008] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxViewControllerAdaptingExtensions.cs:17
at MvvmCross.iOS.Views.MvxViewController..ctor (System.IntPtr handle) [0x00009] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxViewCon
troller.cs:28
at SampleApp.Mobile.iOS.BaseViewController..ctor (System.IntPtr handle) [0x0008c] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Views\BaseViewController.cs:35
at SampleApp.Mobile.iOS.MainView..ctor (System.IntPtr handle) [0x00000] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Views\MainView.cs:16
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/c
lass/corlib/System.Reflection/MonoMethod.cs:667
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:652
at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:680
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, Ob
jCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x0003e] in <512590c9cb4447d89974aa2a90fea66f>:0
at ObjCRuntime.Runtime.ConstructNSObject (System.IntPtr ptr, System.IntPtr klass, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x00013] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:981
at ObjCRuntime.Runtime.GetNSObject (System.IntPtr ptr, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution, System.Boolean evenInFinalizerQueue) [0x00022] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:1099
at ObjCRuntime.Runtime.TryGetOrConstructNSObjectWrapped (System.IntPtr ptr) [0x00000] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:648
at ObjCRuntime.Runtime.try_get_or_construct_nsobject (System.IntPtr obj, System.Int32& exception_gchandle) [0x00003] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/runtime/Delegates.
generated.cs:342
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at SampleApp.Mobile.iOS.Application.Main (System.String[] args) [0x00001] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Main.cs:12
2017-10-25 11:12:34.938 SampleAppMobileiOS[5351:568000] Unhandled managed exception:
Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:667
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:652
at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Library/Frameworks/Xamarin.iOS.framewor
k/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:680
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x0003e] in <512590c9cb4447d89974aa2a90fea66f>:0
at ObjCRuntime.Runtime.ConstructNSObject (System.IntPtr ptr, System.IntPtr klass, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x00013] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:981
at ObjCRuntime.Runtime.GetNSObject (System.IntPtr ptr, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution, System.Boolean evenInFinalizerQueue) [0x00022] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:1099
at ObjCRuntime.Runtime.TryGetOrConstructNSObjectWrapped (System.IntPtr ptr) [0x00000] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:648
at ObjCRuntime.Runtime.try_get_or_construct_nsobject (System.IntPtr obj, System.Int32& exception_gchandle) [0x00003] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/runtime/Delegates.generated.cs:342
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5489/1b460cb9/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Oase
n.DigitaleRotonde.Mobile.iOS.Application.Main (System.String[] args) [0x00001] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Main.cs:12
--- inner exception ---
Object reference not set to an instance of an object (System.NullReferenceException)
at MvvmCross.Platform.Mvx.Resolve[TService] () [0x00006] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.iOS.Views.MvxBindingViewControllerAdapter.HandleViewDidDisappearCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1[T] e) [0x00029] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxBindingViewControllerAdapter.cs:26
at MvvmCross.iOS.Views.MvxViewControllerAdaptingExtensions.AdaptForBinding (MvvmCross.Platform.iOS.Views.IMvxEventSourceViewController view) [0x00008] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxViewControllerAdaptingExtensions.cs:17
at MvvmCross.iOS.Views.MvxViewController..ctor (System.IntPtr handle) [0x00009] in C:\projects\mvvmcross\MvvmCross\iOS\iOS\Views\MvxViewCo
ntroller.cs:28
at SampleApp.Mobile.iOS.BaseViewController..ctor (System.IntPtr handle) [0x0008c] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Views\BaseViewController.cs:35
at SampleApp.Mobile.iOS.MainView..ctor (System.IntPtr handle) [0x00000] in D:\Sample_Mobile\SampleApp.Mobile\SampleApp.Mobile.iOS\Views\MainView.cs:16
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.4.0.93/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661
2017-10-25 11:12:34.939 SampleAppMobileiOS[5351:568000] critical: Stacktrace:
2017-10-25 11:12:34.939 SampleAppMobileiOS[5351:568000] critical:
Native stacktrace:
2017-10-25 11:12:34.953 SampleAppMobileiOS[5351:568000] critical: 0 SampleAppMobileiOS 0x0000000101491b2c SampleAppMobileiOS + 21240620
2017-10-25 11:12:34.954 SampleAppMobileiOS[5351:568000] critical: 1 libsystem_platform.dylib 0x0000000189a5531c _sigtramp + 52
2017-10-25 11:12:34.954 SampleAppMobileiOS[5351:568000] critical: 2 libsystem_pthread.dylib 0x0000000189a5b264 pthread_kill + 112
2017-10-25 11:12:34.955 SampleAppMobileiOS[5351:568000] critical: 3 libsystem_c.dylib 0x00000001899059c4 abort + 140
2017-10-25 11:12:34.955 SampleAppMobileiOS[5351:568000] critical: 4 SampleAppMobileiOS 0x00000001015963dc xamarin_get_block_descriptor + 8260
2017-10-25 11:12:34.956 SampleAppMobileiOS[5351:568000] critical: 5 SampleAppMobileiOS 0x00000001014cf4ec mono_pmip + 216852
2017-10-25 11:12:34.956 SampleAppMobileiOS[5351:568000] critical: 6 SampleAppMobileiOS 0x0000000101491928 SampleAppMobileiOS + 21240104
2017-10-25 11:12:34.957 SampleAppMobileiOS[5351:568000] critical: 7 SampleAppMobileiOS 0x0000000101490738 SampleAppMobileiOS + 21235512
2017-10-25 11:12:34.958 SampleAppMobileiOS[5351:568000] critical: 8 SampleAppMobileiOS 0x0000000101488d1c SampleAppMobileiOS + 21204252
2017-10-25 11:12:34.958 SampleAppMobileiOS[5351:568000] critical: 9 SampleAppMobileiOS 0x0000000100364e68 SampleAppMobileiOS + 3231336
2017-10-25 11:12:34.959 SampleAppMobileiOS[5351:568000] critical: 10 SampleAppMobileiOS 0x0000000101596130 xamarin_get_block_descriptor + 7576
2017-10-25 11:12:34.960 SampleAppMobileiOS[5351:568000] critical: 11 SampleAppMobileiOS 0x0000000101595fb0 xamarin_get_block_descriptor + 7192
2017-10-25 11:12:34.960 SampleAppMobileiOS[5351:568000] critical: 12 SampleAppMobileiOS 0x0000000100062400 SampleAppMobileiOS + 74752
2017-10-25 11:12:34.961 SampleAppMobileiOS[5351:568000] critical: 13 SampleAppMobileiOS 0x000000010006220c SampleAppMobileiOS + 74252
2017-10-25 11:12:34.961 SampleAppMobileiOS[5351:568000] critical: 14 Foundation 0x000000018b3ab64c <redacted> + 272
2017-10-25 11:12:34.962 SampleAppMobileiOS[5351:568000] critical: 15 UIKit 0x0000000190e2c2fc <redacted> + 104
2017-10-25 11:12:34.962 SampleAppMobileiOS[5351:568000] critical: 16 UIKit 0x0000000190fd00d8 <redacted> + 124
2017-10-25 11:12:34.963 SampleAppMobileiOS[5351:568000] critical: 17 CoreFoundation 0x000000018a8b7fac <redacted> + 232
2017-10-25 11:12:34.963 SampleAppMobileiOS[5351:568000] critical: 18 UIKit 0x0000000190fceacc <redacted> + 1696
2017-10-25 11:12:34.964 SampleAppMobileiOS[5351:568000] critical: 19 UIKit 0x0000000190e2f2d4 <redacted> + 372
2017-10-25 11:12:34.964 SampleAppMobileiOS[5351:568000] critical: 20 UIKit 0x0000000190bf946c <redacted> + 176
2017-10-25 11:12:34.965 SampleAppMobileiOS[5351:568000] critical: 21 UIKit 0x0000000190ac7b68 <redacted> + 180
2017-10-25 11:12:34.965 SampleAppMobileiOS[5351:568000] critical: 22 UIKit 0x0000000190b7fff0 <redacted> + 72
2017-10-25 11:12:34.966 SampleAppMobileiOS[5351:568000] critical: 23 UIKit 0x0000000190b7fec8 <redacted> + 416
2017-10-25 11:12:34.966 SampleAppMobileiOS[5351:568000] critical: 24 UIKit 0x0000000190b7f1f8 <redacted> + 144
2017-10-25 11:12:34.966 SampleAppMobileiOS[5351:568000] critical: 25 UIKit 0x0000000190b7ec2c <redacted> + 856
2017-10-25 11:12:34.967 SampleAppMobileiOS[5351:568000] critical: 26 UIKit 0x0000000190b7e7e0 <redacted> + 64
2017-10-25 11:12:34.967 SampleAppMobileiOS[5351:568000] critical: 27 UIKit 0x0000000190b7e744 <redacted> + 188
2017-10-25 11:12:34.967 SampleAppMobileiOS[5351:568000] critical: 28 UIKit 0x0000000190ac507c <redacted> + 1200
2017-10-25 11:12:34.968 SampleAppMobileiOS[5351:568000] critical: 29 QuartzCore 0x000000018dcb5274 <redacted> + 148
2017-10-25 11:12:34.968 SampleAppMobileiOS[5351:568000] critical: 30 QuartzCore 0x000000018dca9de8 <redacted> + 292
2017-10-25 11:12:34.968 SampleAppMobileiOS[5351:568000] critical: 31 QuartzCore 0x000000018dca9ca8 <redacted> + 32
2017-10-25 11:12:34.969 SampleAppMobileiOS[5351:568000] critical: 32 QuartzCore 0x000000018dc2534c <redacted> + 252
2017-10-25 11:12:34.969 SampleAppMobileiOS[5351:568000] critical: 33 QuartzCore 0x000000018dc4c3ac <redacted> + 504
2017-10-25 11:12:34.969 SampleAppMobileiOS[5351:568000] critical: 34 QuartzCore 0x000000018dc4ce78 <redacted> + 120
2017-10-25 11:12:34.969 SampleAppMobileiOS[5351:568000] critical: 35 CoreFoundation 0x000000018a9449a8 <redacted> + 32
2017-10-25 11:12:34.970 SampleAppMobileiOS[5351:568000] critical: 36 CoreFoundation 0x000000018a942630 <redacted> + 372
2017-10-25 11:12:34.970 SampleAppMobileiOS[5351:568000] critical: 37 CoreFoundation 0x000000018a872dc4 CFRunLoopRunSpecific + 456
2017-10-25 11:12:34.970 SampleAppMobileiOS[5351:568000] critical: 38 UIKit 0x0000000190b32384 <redacted> + 652
2017-10-25 11:12:34.971 SampleAppMobileiOS[5351:568000] critical: 39 UIKit 0x0000000190b2d058 UIApplicationMain + 208
2017-10-25 11:12:34.971 SampleAppMobileiOS[5351:568000] critical: 40 SampleAppMobileiOS 0x00000001004552b0 SampleAppMobileiOS + 4215472
2017-10-25 11:12:34.971 SampleAppMobileiOS[5351:568000] critical: 41 SampleAppMobileiOS 0x00000001003fbbdc SampleAppMobileiOS + 3849180
2017-10-25 11:12:34.972 SampleAppMobileiOS[5351:568000] critical: 42 SampleAppMobileiOS 0x00000001003fbb9c SampleAppMobileiOS + 3849116
2017-10-25 11:12:34.972 SampleAppMobileiOS[5351:568000] critical: 43 SampleAppMobileiOS 0x0000000100082d10 SampleAppMobileiOS + 208144
2017-10-25 11:12:34.972 SampleAppMobileiOS[5351:568000] critical: 44 SampleAppMobileiOS 0x0000000100334384 SampleAppMobileiOS + 3031940
2017-10-25 11:12:34.973 SampleAppMobileiOS[5351:568000] critical: 45 SampleAppMobileiOS 0x000000010149fc44 mono_pmip + 22124
2017-10-25 11:12:34.973 SampleAppMobileiOS[5351:568000] critical: 46 SampleAppMobileiOS 0x0000000101507454 mono_pmip + 446076
2017-10-25 11:12:34.973 SampleAppMobileiOS[5351:568000] critical: 47 SampleAppMobileiOS 0x0000000101509fc4 mono_pmip + 457196
2017-10-25 11:12:34.974 SampleAppMobileiOS[5351:568000] critical: 48 SampleAppMobileiOS 0x00000001014884fc SampleAppMobileiOS + 21202172
2017-10-25 11:12:34.974 SampleAppMobileiOS[5351:568000] critical: 49 SampleAppMobileiOS 0x00000001015a4074 _Z9__isctypeim + 46228
2017-10-25 11:12:34.974 SampleAppMobileiOS[5351:568000] critical: 50 SampleAppMobileiOS 0x000000010007611c SampleAppMobileiOS + 155932
2017-10-25 11:12:34.975 SampleAppMobileiOS[5351:568000] critical: 51 libdyld.dylib 0x000000018988159c <redacted> + 4
2017-10-25 11:12:34.975 SampleAppMobileiOS[5351:568000] critical:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
The app has been terminated.
Failed to Stop app: An error occured on client IDB471022 while executing a reply for topic xvs/idb/4.7.10.22/stop-app
The app has been terminated.
The app works fine on mvvmcross 4, and the migration guide shows no surprises: https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-50. I can't seem to debug anything. The only breakpoint that triggers is on UIApplication.Main, and step-into stops quite quickly and results in the given exception. Where do I start searching in order to fix this?
[edit]
This is still an issue, even with MVVMCross 5.7. It tries to instantiate a MainView class, which extends from MvxViewController. This happens before there is any code executed from my Setup class.
Looking at the line 26 that fails in MvxBindingViewControllerAdapter:
IosView.BindingContext = Mvx.Resolve<IMvxBindingContext>();
Where IosView is the ViewController cast to IMvxIosView. This suggests that your ViewController does not implement IMvxIosView. Since it seems like it is the only thing that would be null in this case.
I finally found the answer. I had 2 major versions of MvvmCross included in the project. I've now upgraded everything to 6.x.x. and the application starts up.

UIWebView LoadFinished event crashes on device but not on simulator

I'm trying to create a UIWebView and loading a page. When the loading finishes, I want to move to another screen.
The following code works on the iOS simulator, but not on a device.
I tried following this answer (Monotouch + UIWebView = Random Crashes), promoting the NSUrlRequest to become a global variable, but the error persists.
I tried using a try{} catch{} but it doesn't grab any exceptions when it crashes. it's driving me insane :)
void LoadSite(){
webView = new UIWebView (new CGRect (0, 0, 300,300));
string url = "http://google.com";
NSUrlRequest request = new NSUrlRequest(new NSUrl(url));
View.AddSubview (webView);
webView.LoadFinished+= (object sender, EventArgs e) => {
// CRASHES
};
webView.LoadRequest(request);
}
Any idea of how to solve this?
Thank you.
2015-05-03 19:28:08.465 Baru[5549:638056] critical: Stacktrace:
2015-05-03 19:28:08.466 Baru[5549:638056] critical: at <unknown> <0xffffffff>
2015-05-03 19:28:08.467 Baru[5549:638056] critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend (intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.469 Baru[5549:638056] critical: at ObjCRuntime.Class.GetClassForObject (intptr) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Class.cs:111
2015-05-03 19:28:08.470 Baru[5549:638056] critical: at ObjCRuntime.Runtime.GetNSObject (intptr,System.Type,ObjCRuntime.Runtime/MissingCtorResolution,bool,bool&) [0x00024] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Runtime.cs:836
2015-05-03 19:28:08.471 Baru[5549:638056] critical: at ObjCRuntime.Runtime.GetNSObjectWithType (intptr,intptr,bool&) [0x0000c] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Runtime.cs:383
2015-05-03 19:28:08.472 Baru[5549:638056] critical: at ObjCRuntime.Runtime.get_nsobject_with_type (intptr,intptr,bool&) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/maccore/runtime/Delegates.generated.cs:208
2015-05-03 19:28:08.473 Baru[5549:638056] critical: at (wrapper native-to-managed) ObjCRuntime.Runtime.get_nsobject_with_type (intptr,intptr,int&) <0xffffffff>
2015-05-03 19:28:08.473 Baru[5549:638056] critical: at <unknown> <0xffffffff>
2015-05-03 19:28:08.474 Baru[5549:638056] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.475 Baru[5549:638056] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/UIKit/UIApplication.cs:63
2015-05-03 19:28:08.476 Baru[5549:638056] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/UIKit/UIApplication.cs:46
2015-05-03 19:28:08.476 Baru[5549:638056] critical: at Baru.Application.Main (string[]) [0x00008] in /Users/Montein/Proyectos/BRU/Solution/Baru/Baru/Main.cs:17
2015-05-03 19:28:08.477 Baru[5549:638056] critical: at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.478 Baru[5549:638056] critical:
Native stacktrace:
2015-05-03 19:28:08.552 Baru[5549:638056] critical: 0 Baru 0x00000001003ee998 mono_handle_native_sigsegv + 264
2015-05-03 19:28:08.553 Baru[5549:638056] critical: 1 Baru 0x00000001003f8c6c mono_sigsegv_signal_handler + 324
2015-05-03 19:28:08.554 Baru[5549:638056] critical: 2 libsystem_platform.dylib 0x0000000194da495c _sigtramp + 68
2015-05-03 19:28:08.555 Baru[5549:638056] critical: 3 Baru 0x0000000100139a18 wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_intptr_intptr + 104
2015-05-03 19:28:08.555 Baru[5549:638056] critical: 4 Baru 0x00000001000f9278 ObjCRuntime_Class_GetClassForObject_intptr + 40
2015-05-03 19:28:08.556 Baru[5549:638056] critical: 5 Baru 0x00000001000f17a8 ObjCRuntime_Runtime_GetNSObject_intptr_System_Type_ObjCRuntime_Runtime_MissingCtorResolution_bool_bool_ + 120
2015-05-03 19:28:08.557 Baru[5549:638056] critical: 6 Baru 0x00000001000ef8dc ObjCRuntime_Runtime_GetNSObjectWithType_intptr_intptr_bool_ + 108
2015-05-03 19:28:08.558 Baru[5549:638056] critical: 7 Baru 0x00000001000ede44 ObjCRuntime_Runtime_get_nsobject_with_type_intptr_intptr_bool_ + 36
2015-05-03 19:28:08.558 Baru[5549:638056] critical: 8 Baru 0x0000000100141c48 wrapper_native_to_managed_ObjCRuntime_Runtime_get_nsobject_with_type_intptr_intptr_int_ + 104
2015-05-03 19:28:08.559 Baru[5549:638056] critical: 9 Baru 0x00000001004afb78 xamarin_get_nsobject_with_type + 52
2015-05-03 19:28:08.559 Baru[5549:638056] critical: 10 Baru 0x00000001004afec4 xamarin_get_nsobject_with_type_for_ptr_created + 228
2015-05-03 19:28:08.560 Baru[5549:638056] critical: 11 Baru 0x00000001004b9500 xamarin_trampoline + 3860
2015-05-03 19:28:08.561 Baru[5549:638056] critical: 12 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.561 Baru[5549:638056] critical: 13 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 14 CoreFoundation 0x0000000182c5ae30 <redacted> + 68
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 15 WebKitLegacy 0x00000001924c0898 <redacted> + 172
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 16 CoreFoundation 0x0000000182d57f6c <redacted> + 440
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 17 CoreFoundation 0x0000000182c5accc _CF_forwarding_prep_0 + 92
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 18 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 19 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 20 WebCore 0x000000019164bda8 <redacted> + 212
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 21 WebKitLegacy 0x00000001924c0650 <redacted> + 128
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 22 WebCore 0x0000000191659414 <redacted> + 84
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 23 WebCore 0x0000000191658790 <redacted> + 812
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 24 WebCore 0x0000000191a6d694 <redacted> + 56
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 25 WebCore 0x0000000191658230 <redacted> + 92
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 26 WebCore 0x0000000191658190 <redacted> + 1588
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 27 WebKitLegacy 0x00000001924d0a34 <redacted> + 228
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 28 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 29 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 30 CoreFoundation 0x0000000182c5ae30 <redacted> + 68
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 31 WebKitLegacy 0x00000001924c0898 <redacted> + 172
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 32 CoreFoundation 0x0000000182d57f6c <redacted> + 440
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 33 CoreFoundation 0x0000000182c5accc _CF_forwarding_prep_0 + 92
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 34 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 35 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 36 WebCore 0x0000000191666efc <redacted> + 120
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 37 CoreFoundation 0x0000000182d0c240 <redacted> + 24
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 38 CoreFoundation 0x0000000182d0b4e4 <redacted> + 264
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 39 CoreFoundation 0x0000000182d09594 <redacted> + 712
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 40 CoreFoundation 0x0000000182c352d4 CFRunLoopRunSpecific + 396
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 41 GraphicsServices 0x000000018c44b6fc GSEventRunModal + 168
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 42 UIKit 0x00000001877fafac UIApplicationMain + 1488
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 43 Baru 0x0000000100140d2c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 348
2015-05-03 19:28:08.571 Baru[5549:638056] critical: 44 Baru 0x000000010010b82c UIKit_UIApplication_Main_string___intptr_intptr + 44
2015-05-03 19:28:08.572 Baru[5549:638056] critical: 45 Baru 0x000000010010b7ec UIKit_UIApplication_Main_string___string_string + 172
2015-05-03 19:28:08.572 Baru[5549:638056] critical: 46 Baru 0x00000001000cc11c Baru_Application_Main_string__ + 156
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 47 Baru 0x0000000100267444 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 180
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 48 Baru 0x00000001003faea4 mono_jit_runtime_invoke + 1260
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 49 Baru 0x0000000100448cc4 mono_runtime_invoke + 128
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 50 Baru 0x000000010044cf50 mono_runtime_exec_main + 404
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 51 Baru 0x00000001004aed8c xamarin_main + 1844
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 52 Baru 0x00000001003515b8 main + 96
2015-05-03 19:28:08.575 Baru[5549:638056] critical: 53 libdyld.dylib 0x0000000194bf6a08 <redacted> + 4
2015-05-03 19:28:08.575 Baru[5549:638056] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
It looks good. please refer my code to show progress bar during loading.
it may be
1)Please check the internet connection
2)Debug in appdelege more than 12 sec crashes the application
string url = "http://manikandan.azurewebsites.net";
//Web View
webView.ShouldStartLoad += HandleShouldStartLoad;//Handle every url loads in webview
webView.LoadRequest (new NSUrlRequest (new NSUrl (url)));//Load Url in the same view
webView.LoadStarted += ProgressbarLoad;//Show progress bar while loading webview
void ProgressbarLoad (object sender, EventArgs e)
{
// Determine the correct size to start the overlay (depending on device orientation)
var bounds = UIScreen.MainScreen.Bounds; // portrait bounds
if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight) {
bounds.Size = new SizeF(bounds.Size.Height, bounds.Size.Width);
}
// show the loading overlay on the UI thread using the correct orientation sizing
this._loadPop = new LoadingOverlay (bounds);
this.View.Add ( this._loadPop );
}

MonoTouch SIGSEGV during garbage collector initiated Dispose on ABPeoplePickerNavigationController

Building against MT 6.0.4.
Targeting iOS 4.
Testing on an iPhone 4S.
I'm stumped as to what I am doing wrong. I display the ABPeoplePickerNavigationController modally after subscribing to the SelectPerson event. Within the event, I take a copy of the data I need (only holding references to strings, not to any of the AdressBook or Person instances), and then close the modal dialog:
private string selectedPersonFirstName;
private string selectedPersonEmail;
private string selectedPersonPhone;
private void SelectContact()
{
var peoplePicker = new ABPeoplePickerNavigationController();
peoplePicker.Cancelled += (sender, e) =>
{
selectedPersonFirstName = null;
selectedPersonEmail = null;
selectedPersonPhone = null;
peoplePicker.DismissViewController(true, null);
};
peoplePicker.SelectPerson += (sender, e) =>
{
var selectedName = String.Format("{0} {1}", e.Person.FirstName, e.Person.LastName);
selectedPersonFirstName = e.Person.FirstName;
if ( e.Person.GetEmails().Count > 0)
selectedPersonEmail = e.Person.GetEmails().FirstOrDefault().Value;
if ( e.Person.GetPhones().Count > 0)
selectedPersonPhone = e.Person.GetPhones().FirstOrDefault().Value;
peoplePicker.DismissViewController(true, null);
};
PresentViewController(peoplePicker, true, null);
}
At some point later when the GC kicks in, it crashes:
Stacktrace:
at MonoTouch.Foundation.NSObject.FinishDispose () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:158
at MonoTouch.Foundation.NSObject/MonoTouch_Disposer.Drain (MonoTouch.Foundation.NSObject) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:376
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at MyApp.iOS.Application.Main (string[]) [0x00000] in /Users/tyson/Code/MyApp/iOS/Main.cs:19
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
0 MyAppName--------------- 0x00f574f4 mono_handle_native_sigsegv + 280
1 MyAppName--------------- 0x00f3a2b8 mono_sigsegv_signal_handler + 268
2 libsystem_c.dylib 0x31ae97ed _sigtramp + 48
3 CoreFoundation 0x3745b2e7 CFRelease + 94
4 AddressBookUI 0x373922d1 -[ABGroupWrapper dealloc] + 100
5 libobjc.A.dylib 0x35a14175 _objc_rootRelease + 36
6 AddressBookUI 0x373a3f57 -[ABModel dealloc] + 146
7 libobjc.A.dylib 0x35a14175 _objc_rootRelease + 36
8 AddressBookUI 0x373aec43 -[ABAbstractViewController dealloc] + 38
9 AddressBookUI 0x373aeb3d -[ABMembersViewController dealloc] + 216
10 libobjc.A.dylib 0x35a14175 _objc_rootRelease + 36
11 CoreFoundation 0x3745b2e7 CFRelease + 94
12 CoreFoundation 0x3747106b -[__NSArrayM dealloc] + 122
13 libobjc.A.dylib 0x35a14175 _objc_rootRelease + 36
14 UIKit 0x33c891b9 -[UIViewController dealloc] + 496
15 UIKit 0x33c88f2f -[UINavigationController dealloc] + 198
16 AddressBookUI 0x373adcbd -[ABPeoplePickerNavigationController dealloc] + 376
17 libobjc.A.dylib 0x35a14175 _objc_rootRelease + 36
18 MyAppName--------------- 0x001e1ccc wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_intptr_intptr + 68
19 MyAppName--------------- 0x001ad49c MonoTouch_Foundation_NSObject_MonoTouch_Disposer_Drain_MonoTouch_Foundation_NSObject + 364
20 MyAppName--------------- 0x006997b8 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
21 MyAppName--------------- 0x00f3c6a4 mono_jit_runtime_invoke + 1644
22 MyAppName--------------- 0x00ff5dc0 mono_runtime_invoke + 128
23 MyAppName--------------- 0x00f2c6ec native_to_managed_trampoline_MonoTouch_Foundation_NSObject_MonoTouch_Disposer_Drain + 280
24 CoreFoundation 0x374a0eef +[NSObject performSelector:withObject:] + 42
25 Foundation 0x37d51747 __NSThreadPerformPerform + 350
26 CoreFoundation 0x374e6ad3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
27 CoreFoundation 0x374e629f __CFRunLoopDoSources0 + 214
28 CoreFoundation 0x374e5045 __CFRunLoopRun + 652
29 CoreFoundation 0x374684a5 CFRunLoopRunSpecific + 300
30 CoreFoundation 0x3746836d CFRunLoopRunInMode + 104
31 GraphicsServices 0x32375439 GSEventRunModal + 136
32 UIKit 0x33bece7d UIApplicationMain + 1080
33 MyAppName--------------- 0x001e6ca4 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
34 MyAppName--------------- 0x00ee0210 MyApp_iOS_Application_Main_string__ + 152
35 MyAppName--------------- 0x006997b8 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
36 MyAppName--------------- 0x00f3c6a4 mono_jit_runtime_invoke + 1644
37 MyAppName--------------- 0x00ff5dc0 mono_runtime_invoke + 128
38 MyAppName--------------- 0x00ffa224 mono_runtime_exec_main + 436
39 MyAppName--------------- 0x00fff770 mono_runtime_run_main + 756
40 MyAppName--------------- 0x00f434a4 mono_jit_exec + 140
41 MyAppName--------------- 0x0105c04c main + 2028
42 MyAppName--------------- 0x0001bd18 start + 40
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Has anyone seen anything like this before? I'm up for workarounds at this point as I need it more reliable for a demo ASAP (not for app store submission yet).
It looks like a bug. Something gets released one time too many and crash.
You can, for your demonstration purpose, work around it by defining CFRetain like this:
[System.Runtime.InteropServices.DllImport ("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
static extern IntPtr CFRetain (IntPtr obj);
and use it on the _AddressBook, like that
peoplePicker.SelectPerson += (sender, e) => {
CFRetain (peoplePicker._AddressBook);
var selectedName = String.Format("{0} {1}", e.Person.FirstName, e.Person.LastName);
...
That will balance the count and avoid the crash.
Update: bug filled, you can c.c. yourself the the bug report to know when a fix will be released.

App crashes after Monotouch update to 5.2.13

After I have updated monotouch to Version 5.2.13 my App crashes when I touched inside a UIButton.
About my Code: (it's a question of a LoginView):
I have a UIViewController which includes a ScrollView.
For each User the ScrollView provides a UIView (the UserImageView).
This UserImageView contains a UserImage, Username and so on. Over the UserImage lays a UIButton which should catches the Touch-Events to selected a User.
This Button causes the Exception below more precisely the HitTest method from the UIView.
I get the following Stacktrace:
Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at MF.Stationaer.iPad.Application.Main (string[]) <IL 0x00028, 0x00073>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 MFiPad_MD 0x0009061c mono_handle_native_sigsegv + 284
1 MFiPad_MD 0x000059a8 mono_sigsegv_signal_handler + 248
2 libsystem_c.dylib 0x92cd259b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 UIKit 0x0228c741 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 96
5 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
6 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
7 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
8 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
9 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
10 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
11 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
12 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
13 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
14 UIKit 0x022a1157 -[UIScrollView hitTest:withEvent:] + 79
15 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
16 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
17 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
18 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
19 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
20 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
21 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
22 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
23 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
24 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
25 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
26 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
27 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
28 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
29 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
30 UIKit 0x02286dbd +[UIWindow _hitTestToPoint:pathIndex:forEvent:] + 378
31 UIKit 0x02258ca0 _UIApplicationHandleEvent + 1648
32 GraphicsServices 0x047c5ef5 PurpleEventCallback + 1274
33 CoreFoundation 0x011a9195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
34 CoreFoundation 0x0110dff2 __CFRunLoopDoSource1 + 146
35 CoreFoundation 0x0110c8da __CFRunLoopRun + 2218
36 CoreFoundation 0x0110bd84 CFRunLoopRunSpecific + 212
37 CoreFoundation 0x0110bc9b CFRunLoopRunInMode + 123
38 GraphicsServices 0x047c47d8 GSEventRunModal + 190
39 GraphicsServices 0x047c488a GSEventRun + 103
40 UIKit 0x02258626 UIApplicationMain + 1163
41 ??? 0x0b96e514 0x0 + 194438420
42 ??? 0x0b96d6c0 0x0 + 194434752
43 ??? 0x0b96d33c 0x0 + 194433852
44 ??? 0x0b96d42f 0x0 + 194434095
45 MFiPad_MD 0x00009d12 mono_jit_runtime_invoke + 722
46 MFiPad_MD 0x00169e4e mono_runtime_invoke + 126
47 MFiPad_MD 0x0016df34 mono_runtime_exec_main + 420
48 MFiPad_MD 0x001732e5 mono_runtime_run_main + 725
49 MFiPad_MD 0x00066f15 mono_jit_exec + 149
50 MFiPad_MD 0x002115d5 main + 2837
51 MFiPad_MD 0x00002d65 start + 53
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
Here is the important Part of my Code:
public class LoginViewController : UIViewController
{
...
public override void ViewDidLoad()
{
...
BuildUserUI();
...
}
private void BuildUserUI()
{
currentIconLocation = new PointF(50, 10);
for (var i = 0; i < UserList.List.Count; i++)
CreateUserInGrid(UserList.GetUserByIndex(i));
}
private void CreateUserInGrid(LoginUser user)
{
var imgFrame = new RectangleF(currentIconLocation.X, currentIconLocation.Y, 140, 170);
var loginImg = new UILoginImage(imgFrame);
loginImg.Image = user.Image ?? defaultUserImage.CGImage;
loginImg.Name = user.Nachname;
if (!string.IsNullOrEmpty(user.Vorname))
loginImg.Name += ", " + user.Vorname;
loginImg.Tag = user.UserIndex;
loginImg.AddTarget(this, new Selector("ShowNumberPad:"), UIControlEvent.TouchUpInside);
loginImg.LoginUser = user;
scrollView.AddSubview(loginImg);
loginImages.Add(loginImg);
limitedScrollView.UserInteractionEnabled = false;
var newSize = new SizeF(scrollView.Frame.Size.Width, currentIconLocation.Y + imgFrame.Size.Height + 20);
scrollView.ContentSize = newSize;
limitedScrollView.ContentSize = new SizeF(limitedScrollView.Frame.Size.Width, limitedScrollView.Frame.Size.Height);
currentIconLocation.X += imgFrame.Size.Width;
if (currentIconLocation.X + imgFrame.Size.Width > scrollView.Frame.Size.Width)
{
currentIconLocation.Y += imgFrame.Size.Height;
currentIconLocation.X = 50;
}
}
[Export("ShowNumberPad:")]
private void ShowNumberPad(NSObject sender)
{
...
}
}
public class UILoginImage : UIView
{
[Export("initWithFrame:")]
public UILoginImage(RectangleF frame)
: base(frame)
{
var shadowFrame = new RectangleF(0, 0, 117, 148);
wrapperControl = new UIControl(shadowFrame);
AddSubview(wrapperControl);
shadowImage = new UIImageView(shadowFrame);
shadowImage.Image = ImageCache.GetResourceImage("Images/Login/LoginSchatten.png");
wrapperControl.AddSubview(shadowImage);
var mainBackFrame = new RectangleF(8, 9, 98, 128);
whiteBackgroundImage = new UIImageView(mainBackFrame);
whiteBackgroundImage.Image = ImageCache.GetResourceImage("Images/Login/Singlewhite.png");
wrapperControl.AddSubview(whiteBackgroundImage);
var imageFrame = new RectangleF(13, 15, 87, 116);
clickHelper = UIButton.FromType(UIButtonType.Custom);
clickHelper.Frame = imageFrame;
wrapperControl.AddSubview(clickHelper);
userImage = new UIImageView(imageFrame);
AddSubview(userImage);
var mitarbeiterlabelFrame = new RectangleF(-12, 137, 140, 25);
mitarbeiterNameLabel = new FontSizeLabel(mitarbeiterlabelFrame);
mitarbeiterNameLabel.TextAlignment = UITextAlignment.Center;
mitarbeiterNameLabel.Font = UIFont.SystemFontOfSize(12);
mitarbeiterNameLabel.Opaque = false;
mitarbeiterNameLabel.BackgroundColor = UIColor.Clear;
AddSubview(mitarbeiterNameLabel);
var benutzerlabelFrame = new RectangleF(mitarbeiterlabelFrame.X, mitarbeiterlabelFrame.Y + 13, 140, 25);
benutzerNameLabel = new FontSizeLabel(benutzerlabelFrame);
benutzerNameLabel.TextAlignment = UITextAlignment.Center;
benutzerNameLabel.Font = UIFont.SystemFontOfSize(10);
benutzerNameLabel.Opaque = false;
benutzerNameLabel.BackgroundColor = UIColor.Clear;
benutzerNameLabel.TextColor = UIColor.DarkGray;
AddSubview(benutzerNameLabel);
}
public void AddTarget(NSObject target, Selector action, UIControlEvent controlEvents)
{
clickHelper.AddTarget(target, action, controlEvents);
}
public void RemoveTarget(NSObject target, Selector action, UIControlEvent controlEvents)
{
clickHelper.RemoveTarget(target, action, controlEvents);
}
}
I'm not sure your use of AddTarget is a good way to hook up a UIButton's click.
You should be using clickHelper.TouchUpInside to wire up click events. This is a standard C# event.
Another option would be to wire up an action to this event inside your XIB file in XCode.

Resources