xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] Visual Element(like Page or StackLayout) crashes inside constructor #15700

Closed DmitryNikiforovCoherent closed 1 year ago

DmitryNikiforovCoherent commented 1 year ago

Description

Application crashes with System.IndexOutOfRangeException: Index was outside the bounds of the array, when create VisualElement(can be appeared with different, StackLayout and Page)

Steps to Reproduce

  1. Not sure, just several crashes appeared on analytics with stacktrace
  2. Dictionary2[TKey,TValue].TryGetValue (TKey key, TValue& value) ResourceDictionary.TryGetValueAndSource (System.String key, System.Object& value, Xamarin.Forms.ResourceDictionary& source) ResourceDictionary.TryGetValue (System.String key, System.Object& value) ResourcesExtensions.TryGetResource (Xamarin.Forms.IElement element, System.String key, System.Object& value) Element.OnSetDynamicResource (Xamarin.Forms.BindableProperty property, System.String key) BindableObject.SetDynamicResource (Xamarin.Forms.BindableProperty property, System.String key, System.Boolean fromStyle) BindableObject.SetDynamicResource (Xamarin.Forms.BindableProperty property, System.String key) MergedStyle.RegisterImplicitStyles () Xamarin.Forms.MergedStyle..ctor (System.Type targetType, Xamarin.Forms.BindableObject target) [0x0001f] in <1693287603d24707b07b71d38f4122f3>:0 Xamarin.Forms.NavigableElement..ctor () [0x00018] in <1693287603d24707b07b71d38f4122f3>:0 Xamarin.Forms.VisualElement..ctor () [0x00059] in <1693287603d24707b07b71d38f4122f3>:0`

Expected Behavior

Visual element successfully created

Actual Behavior

Crash

Basic Information

Environment

Show/Hide Visual Studio info ``` Microsoft Visual Studio Community 2022 Version 17.4.1 VisualStudio.17.Release/17.4.1+33110.190 Microsoft .NET Framework Version 4.8.04084 Installed Version: Community ASP.NET and Web Tools 17.4.326.54890 ASP.NET and Web Tools Azure App Service Tools v3.0.0 17.4.326.54890 Azure App Service Tools v3.0.0 C# Tools 4.4.0-6.22559.4+d7e8a398ef479a908e76bded82150c39251d0c9c C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Extensibility Message Bus 1.4.1 (main@2ee106a) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.4.19 (8c0a575) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0 Provides languages services for ASP.NET Core Razor. TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 4.4.0-6.22559.4+d7e8a398ef479a908e76bded82150c39251d0c9c Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info Xamarin 17.4.0.301 (d17-4@96af3ae) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.4.2 (c457c97) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 13.1.0.1 (d17-4/13ba222) Xamarin.Android Reference Assemblies and MSBuild support. Mono: a96bde9 Java.Interop: xamarin/java.interop/d17-4@fcc33ce2 SQLite: xamarin/sqlite/3.39.3@23e1ae7 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a Xamarin.iOS and Xamarin.Mac SDK 16.0.0.92 (3dd3dc52c) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```

Build Logs

Screenshots

Reproduction Link

Workaround

jfversluis commented 1 year ago

Without any reproduction or sample source this will be impossible to diagnose or trace where this might be coming from. I appreciate the report, but this is not actionable in the current state.

If you manage to uncover more information, please feel free to add it or open something new. Thanks!