Skip to content

Adding a PickerField causes MAUI App crash in iOS #23122

Closed
@mshenoy83

Description

@mshenoy83

Description

Adding a PickerField to a MAUI App causes the App to Crash with this error

ObjCRuntime.ObjCException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIBarButtonItem initWithBarButtonSystemItem:primaryAction:menu:]: unrecognized selector sent to instance 0x1350506d0
Native stack trace:
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804032f4 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00000001803f7fe0 forwarding + 1440
4 CoreFoundation 0x00000001803fa07c _CF_forwarding_prep_0 + 92
5 libxamarin-dotnet-debug.dylib 0x0000000100d2d330 xamarin_dyn_objc_msgSend + 160
6 libmonosgen-2.0.dylib 0x0000000101082804 do_icall + 316
7 libmonosgen-2.0.dylib 0x0000000101080d24 do_icall_wrapper + 356
8 libmonosgen-2.0.dylib 0x0000000101075648 mono_interp_exec_method + 2456
9 libmonosgen-2.0.dylib 0x000000010107327c interp_runtime_invoke + 244
10 libmonosgen-2.0.dylib 0x0000000100f8eca0 mono_jit_runtime_invoke + 1244
11 libmonosgen-2.0.dylib 0x000000010114d54c mono_runtime_invoke_checked + 148
12 libmonosgen-2.0.dylib 0x0000000101151124 mono_runtime_invoke + 540
13 libxamarin-dotnet-debug.dylib 0x0000000100d24180 xamarin_invoke_trampoline + 5424
14 libxamarin-dotnet-debug.dylib 0x0000000100d2c008 xamarin_arch_trampoline + 148
15 libxamarin-dotnet-debug.dylib 0x0000000100d2d204 xamarin_arm64_common_trampoline + 64
16 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
17 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
18 UIKitCore 0x0000000184572730 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 172
19 UIKitCore 0x0000000184572a48 -[UINavigationController _startTransition:fromViewController:toViewController:] + 192
20 UIKitCore 0x0000000184573938 -[UINavigationController _startDeferredTransitionIfNeeded:] + 864
21 UIKitCore 0x0000000184574c88 -[UINavigationController __viewWillLayoutSubviews] + 164
22 UIKitCore 0x00000001845558b8 -[UILayoutContainerView layoutSubviews] + 224
23 UIKitCore 0x00000001852f7434 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2588
24 QuartzCore 0x000000018852c8ec _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 472
25 QuartzCore 0x00000001885376f0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 116
26 QuartzCore 0x000000018847053c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 448
27 QuartzCore 0x000000018849c554 _ZN2CA11Transaction6commitEv + 696
28 UIKitCore 0x0000000184da5f54 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 40
29 CoreFoundation 0x0000000180361f94 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 20
30 CoreFoundation 0x0000000180361268 __CFRunLoopDoBlocks + 408
31 CoreFoundation 0x000000018035ba2c __CFRunLoopRun + 764
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libxamarin-dotnet-debug.dylib 0x0000000100cdda94 xamarin_UIApplicationMain + 60
37 libmonosgen-2.0.dylib 0x0000000101082804 do_icall + 316
38 libmonosgen-2.0.dylib 0x0000000101080d24 do_icall_wrapper + 356
39 libmonosgen-2.0.dylib 0x0000000101075648 mono_interp_exec_method + 2456
40 libmonosgen-2.0.dylib 0x000000010107327c interp_runtime_invoke + 244
41 libmonosgen-2.0.dylib 0x0000000100f8eca0 mono_jit_runtime_invoke + 1244
42 libmonosgen-2.0.dylib 0x000000010114d54c mono_runtime_invoke_checked + 148
43 libmonosgen-2.0.dylib 0x00000001011547ac mono_runtime_exec_main_checked + 116
44 libmonosgen-2.0.dylib 0x0000000100fe1db4 mono_jit_exec + 364
45 libxamarin-dotnet-debug.dylib 0x0000000100d2bea4 xamarin_main + 2032
46 MauiApp3 0x000000010027c494 main + 64
47 dyld 0x00000001006adcd8 start_sim + 20
48 ??? 0x00000001008eab98 0x0 + 4304317336

at UIKit.UIBarButtonItem..ctor(UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu menu) in /Users/builder/azdo/_work/1/s/macios/src/build/dotnet/ios/generated-sources/UIKit/UIBarButtonItem.g.cs:line 363
at UIKit.UIBarButtonItem..ctor(UIBarButtonSystemItem systemItem, EventHandler handler) in /Users/builder/azdo/_work/1/s/macios/src/UIKit/UIBarButtonItem.cs:line 63
at Microsoft.Maui.Platform.MauiDoneAccessoryView..ctor(Action doneClicked)
at Microsoft.Maui.Handlers.PickerHandler.CreatePlatformView()
at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiPicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView(IScrollView scrollView, IScrollViewHandler handler)
at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView)
at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=18.5.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=18.5.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context)
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer(Page page, ShellContent shellContent)
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/macios/src/UIKit/UIApplication.cs:line 69
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/macios/src/UIKit/UIApplication.cs:line 104
at MauiApp3.Program.Main(String[] args) in /Users/maddy/Code/Github/MauiPickerFieldCrash/MauiApp3/Platforms/iOS/Program.cs:line 13
Native stack trace:
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804032f4 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00000001803f7fe0 forwarding + 1440
4 CoreFoundation 0x00000001803fa07c _CF_forwarding_prep_0 + 92
5 libxamarin-dotnet-debug.dylib 0x0000000100d2d330 xamarin_dyn_objc_msgSend + 160
6 libmonosgen-2.0.dylib 0x0000000101082804 do_icall + 316
7 libmonosgen-2.0.dylib 0x0000000101080d24 do_icall_wrapper + 356
8 libmonosgen-2.0.dylib 0x0000000101075648 mono_interp_exec_method + 2456
9 libmonosgen-2.0.dylib 0x000000010107327c interp_runtime_invoke + 244
10 libmonosgen-2.0.dylib 0x0000000100f8eca0 mono_jit_runtime_invoke + 1244
11 libmonosgen-2.0.dylib 0x000000010114d54c mono_runtime_invoke_checked + 148
12 libmonosgen-2.0.dylib 0x0000000101151124 mono_runtime_invoke + 540
13 libxamarin-dotnet-debug.dylib 0x0000000100d24180 xamarin_invoke_trampoline + 5424
14 libxamarin-dotnet-debug.dylib 0x0000000100d2c008 xamarin_arch_trampoline + 148
15 libxamarin-dotnet-debug.dylib 0x0000000100d2d204 xamarin_arm64_common_trampoline + 64
16 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
17 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
18 UIKitCore 0x0000000184572730 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 172
19 UIKitCore 0x0000000184572a48 -[UINavigationController _startTransition:fromViewController:toViewController:] + 192
20 UIKitCore 0x0000000184573938 -[UINavigationController _startDeferredTransitionIfNeeded:] + 864
21 UIKitCore 0x0000000184574c88 -[UINavigationController __viewWillLayoutSubviews] + 164
22 UIKitCore 0x00000001845558b8 -[UILayoutContainerView layoutSubviews] + 224
23 UIKitCore 0x00000001852f7434 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2588
24 QuartzCore 0x000000018852c8ec _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 472
25 QuartzCore 0x00000001885376f0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 116
26 QuartzCore 0x000000018847053c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 448
27 QuartzCore 0x000000018849c554 _ZN2CA11Transaction6commitEv + 696
28 UIKitCore 0x0000000184da5f54 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 40
29 CoreFoundation 0x0000000180361f94 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 20
30 CoreFoundation 0x0000000180361268 __CFRunLoopDoBlocks + 408
31 CoreFoundation 0x000000018035ba2c __CFRunLoopRun + 764
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libxamarin-dotnet-debug.dylib 0x0000000100cdda94 xamarin_UIApplicationMain + 60
37 libmonosgen-2.0.dylib 0x0000000101082804 do_icall + 316
38 libmonosgen-2.0.dylib 0x0000000101080d24 do_icall_wrapper + 356
39 libmonosgen-2.0.dylib 0x0000000101075648 mono_interp_exec_method + 2456
40 libmonosgen-2.0.dylib 0x000000010107327c interp_runtime_invoke + 244
41 libmonosgen-2.0.dylib 0x0000000100f8eca0 mono_jit_runtime_invoke + 1244
42 libmonosgen-2.0.dylib 0x000000010114d54c mono_runtime_invoke_checked + 148
43 libmonosgen-2.0.dylib 0x00000001011547ac mono_runtime_exec_main_checked + 116
44 libmonosgen-2.0.dylib 0x0000000100fe1db4 mono_jit_exec + 364
45 libxamarin-dotnet-debug.dylib 0x0000000100d2bea4 xamarin_main + 2032
46 MauiApp3 0x000000010027c494 main + 64
47 dyld 0x00000001006adcd8 start_sim + 20
48 ??? 0x00000001008eab98 0x0 + 4304317336

Steps to Reproduce

Created a new MAUI App and just add a Picker Field.
I have XCode 16.4

I didnt get the option to select 9.0.80 SR8 as option so I selected 9.0.7

my dotnet workloads

Installed Workload Id Manifest Version Installation Source

maui 9.0.51/9.0.100 SDK 9.0.300
maui-android 9.0.51/9.0.100 SDK 9.0.300
maui-ios 9.0.51/9.0.100 SDK 9.0.300

dotnet info

dotnet --info
.NET SDK:
Version: 9.0.301
Commit: a596cd22e2
Workload version: 9.0.300-manifests.e42facbb
MSBuild version: 17.14.5+edd3bbf37

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.5
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.301/

.NET workloads installed:
[maui-ios]
Installation Source: SDK 9.0.300
Manifest Version: 9.0.51/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.51/WorkloadManifest.json
Install Type: FileBased

Manifest Version: 9.0.51/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.51/WorkloadManifest.json
Install Type: FileBased

[maui]
Installation Source: SDK 9.0.300
Manifest Version: 9.0.51/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.51/WorkloadManifest.json
Install Type: FileBased

Configured to use loose manifests when installing new manifests.

Link to public reproduction project repository

https://github.com/mshenoy83/MauiPickerFieldCrash

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.70 SR7

Affected platforms

iOS

Affected platform versions

iOS 18.5.9199

Did you find any workaround?

No

Relevant log output

Metadata

Metadata

Assignees

Labels

bugIf an issue is a bug or a pull request a bug fixregressionThe issue or pull request is a regression

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions