xamarin/Xamarin.Forms

Application crashes with MissingMethodException - Default constructor not found for type System.Array

Open

#3,790 opened on Sep 14, 2018

 (1 comment) (0 reactions) (1 assignee)C# (1,926 forks)batch import
a/Xaml </>e/3 :clock3:help wantedi/highinactivet/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

iOS application crashes when using the x:Array XAML markup extension, when XAML compilation is turned off and linker set to Link Framework SDKs only.

Not really sure if this bug reports belongs here or in https://github.com/xamarin/xamarin-macios

Steps to Reproduce

  1. Download the FormsGallery sample https://developer.xamarin.com/samples/xamarin-forms/FormsGallery/
  2. Comment out the global XAML compilation directive [assembly: XamlCompilation(XamlCompilationOptions.Compile] in App.xaml.cs. This disables XAML compilation.
  3. Set the iOS project as startup project.
  4. Configure the app to target a physical iOS device. Alternatively, change the Debug build configuration to Link Framework SDKs Only and target a simulator
  5. Build the app
  6. Run it in debug mode
  7. Choose the XAML Pages tab (not the C# code samples tab)
  8. Scroll down in the list and tap on the ListView sample
  9. The app will crash

Expected Behavior

The ListView XAML example page is displayed.

Actual Behavior

The application crashes. See https://gist.github.com/valentinba/a1716c4fd7b5e4f76901bf2ce28f1b5e for the crash details.

Basic Information

Screenshots

N/A

Reproduction Link

Download it from here https://developer.xamarin.com/samples/xamarin-forms/FormsGallery/

Additional information

Some investigation revealed that the problem happens consistently with an application which is:

  • larger in size (not trivial)
  • configured the iOS build linker to Link framework SDKs Only
  • not using XAML compilation

The problem can be mitigated by:

  • avoid using x:Array markup extension and instead populate the list view from code
  • using XAML compilation or
  • configuring the linker to not link (shrink) any assemblies

Other people have run into this or something similar https://github.com/alexrainman/CarouselView/issues/100 and have chosen to work around the issue. And one more https://github.com/alexrainman/CarouselView/issues/418.

Contributor guide