maui: x:Array as resource with key crashes app on device launch
Description
This works in the iOS simulator and on desktop. The goal is to have an array of data I can reuse by key.
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<x:Array Type="{x:Type x:String}" x:Key="CategoriesArray">
<x:String>Noodles</x:String>
<x:String>Rice</x:String>
<x:String>Appetizers</x:String>
<x:String>Desserts</x:String>
<x:String>Beverages</x:String>
</x:Array>
</ResourceDictionary>
This initially was in the Styles.xaml which I split apart for troubleshooting and used merged dictionaries.
That doesn’t work on an iOS device. I get an error about the type converter failing.
The below however does work on the ContentPages:
<BindableLayout.ItemsSource>
<x:Array Type="{x:Type x:String}" >
<x:String>Noodles</x:String>
<x:String>Rice</x:String>
<x:String>Appetizers</x:String>
<x:String>Desserts</x:String>
<x:String>Beverages</x:String>
</x:Array>
</BindableLayout.ItemsSource>
Steps to Reproduce
Add an array with key to your styles, bind to a BindableLayout, and then run on an iOS device.
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 15
Did you find any workaround?
don’t use a resource
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 18 (13 by maintainers)
Commits related to this issue
- [xaml] fix x:Array and x:Double in Release mode Fixes: https://github.com/dotnet/maui/issues/9422 Context: https://github.com/dotnet/maui/blob/51df629f946122945cee8f57baed80eb48e45c4e/src/Controls/sr... — committed to jonathanpeppers/maui by jonathanpeppers a year ago
- [xaml] fix x:Array and x:Double in Release mode (#14546) Fixes: https://github.com/dotnet/maui/issues/9422 Context: https://github.com/dotnet/maui/blob/51df629f946122945cee8f57baed80eb48e45c4e/src/C... — committed to dotnet/maui by jonathanpeppers a year ago
- [xaml] fix x:Array and x:Double in Release mode (#14546) Fixes: https://github.com/dotnet/maui/issues/9422 Context: https://github.com/dotnet/maui/blob/51df629f946122945cee8f57baed80eb48e45c4e/src/Co... — committed to dotnet/maui by hartez a year ago
- [xaml] fix x:Array and x:Double in Release mode (#14546) (#15457) Fixes: https://github.com/dotnet/maui/issues/9422 Context: https://github.com/dotnet/maui/blob/51df629f946122945cee8f57baed80eb48e45... — committed to dotnet/maui by hartez a year ago
Hi,
The issue happens also when we publish Android app with AOT enable.
Regards.
I can also attest that this issue is still happening. On a blank MAUI template project, adding
x:Stringentries to theStyles.xamlresource dictionary causes the app to crash when it is deployed to a device (iOS and Android). Interestingly, it only occurs when<MtouchLink>is set toSdkOnlyin the csproj file. If it is set toNone, the problem goes away.This is a serious blocker to a project I am working on.
My workload version are as follows:
Hope this issue can be fixed in the near future.
Hello friends,
I just wanted to share that this issue is still happening and it forced me to remove any reference to x:Double and x:String on my styles resource dictionary, so I could be able to run the application on DEBUG mode + Link SDK Assemblies only selected on iOS, just to figure out an issue on release mode only was facing. 😉
If you need anything from me =), please let me know I will be happy to share anything you need to reproduce the issue, however our friend @davidortinau I believe he explained it very simple and how to reproduce it.
Thanks for the help with this and anything related with .NET MAUI 👍🏻. Really appreciate it.