Our UWP app crashes with the following error when build in release mode:
Exception thrown at 0x756735D2 (KernelBase.dll) in Pim.MobileApp.UWP.exe: WinRT originate error - 0x80004005 : 'Failed to assign to property 'Windows.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'.'.
Exception thrown at 0x756735D2 (KernelBase.dll) in Pim.MobileApp.UWP.exe: WinRT originate error - 0x802B000A : 'Cannot deserialize XBF metadata type list as 'PageControl' was not found in namespace 'Xamarin.Forms.Platform.UWP'. [Line: 0 Position: 0]'.
This happens with the first 4.3 package at the Xamarin.Forms.Init call. Downgrading to 4.2 works fine. Building in debug mode with version 4.3 also works fine.
Googling suggested most of these errors occur with Merged Dictionaries but we have no merged dictionaries in our UWP app. Just one single resource dictonary in the App.xaml of the shared class library (.net standard)
No crash with 4.3
Application crashes on startup
<?xml version="1.0" encoding="utf-8" ?>
xmlns:prism="clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms"
xmlns:converters="clr-namespace:Pim.MobileApp.Converters"
x:Class="Pim.MobileApp.App">
<converters:ItemTappedEventArgsConverter x:Key="ItemTappedConverter" />
<converters:BooleanToObjectConverter x:Key="selectedOrDeselectedImage" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Image">
<Setter Property="Source" Value="Deselected.png" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Image">
<Setter Property="Source" Value="Selected.png" />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
</converters:BooleanToObjectConverter>
<!--#region Validatie-->
<Style x:Key="validationStyle" TargetType="Label">
<Setter Property="FontSize" Value="Small" />
<Setter Property="FontFamily" Value="{DynamicResource fontFamiliy}" />
<Setter Property="TextColor" Value="{DynamicResource redColor}" />
</Style>
<converters:BooleanToObjectConverter x:Key="requiredMessage" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="Text" Value="Dit veld is verplicht" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="HeightRequest" Value="0" />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
</converters:BooleanToObjectConverter>
<converters:BooleanToObjectConverter x:Key="rangeMessage" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="Text" Value="De waarde valt buiten de min/max range." />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="HeightRequest" Value="0" />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
</converters:BooleanToObjectConverter>
<converters:NullableBooleanToObjectConverter x:Key="eisMessage" x:TypeArguments="Style">
<converters:NullableBooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="TextColor" Value="{DynamicResource redColor}" />
</Style>
</converters:NullableBooleanToObjectConverter.FalseObject>
<converters:NullableBooleanToObjectConverter.TrueObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="TextColor" Value="{DynamicResource textColor}" />
</Style>
</converters:NullableBooleanToObjectConverter.TrueObject>
<converters:NullableBooleanToObjectConverter.NullObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="TextColor" Value="{DynamicResource blueColor}" />
</Style>
</converters:NullableBooleanToObjectConverter.NullObject>
</converters:NullableBooleanToObjectConverter>
<converters:BooleanToObjectConverter x:Key="verdichtingsgraadBerekeningFout" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="Text" Value="De verdichtingsgraad kan niet worden berekend omdat de streefdichtheid van het geselecteerde mengsel niet is gespecificeerd." />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="HeightRequest" Value="0" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
</converters:BooleanToObjectConverter>
<converters:BooleanToObjectConverter x:Key="holleRuimteBerekeningFout" x:TypeArguments="Style">
<converters:BooleanToObjectConverter.TrueObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="Text" Value="De holle ruimte kan niet worden berekend omdat de mengseldichtheid van het geselecteerde mengsel niet is gespecificeerd." />
</Style>
</converters:BooleanToObjectConverter.TrueObject>
<converters:BooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource validationStyle}">
<Setter Property="HeightRequest" Value="0" />
</Style>
</converters:BooleanToObjectConverter.FalseObject>
</converters:BooleanToObjectConverter>
<!--#endregion-->
<!--#region Other converters-->
<converters:DateTimeUtcToTextConverter x:Key="dateTimeUtcToText" />
<!--#endregion-->
<!--#region Button-->
<Style x:Key="dashboardButtonStyle" TargetType="Button">
<Setter Property="TextColor" Value="{DynamicResource textColor}" />
<Setter Property="FontFamily" Value="{DynamicResource fontFamiliy}" />
<Setter Property="BackgroundColor" Value="White" />
</Style>
<OnPlatform x:Key="navigateButtonOpacity" x:TypeArguments="x:Double">
<On Platform="iOS" Value="1" />
<On Platform="Android" Value="0" />
<On Platform="UWP" Value="0" />
</OnPlatform>
<Style x:Key="navigateButtonStyle" TargetType="Button">
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="BorderWidth" Value="0" />
<Setter Property="Opacity" Value="{DynamicResource navigateButtonOpacity}" />
</Style>
<!--#endregion-->
<!--#region ContentPage-->
<Style x:Key="contentPageStyle" TargetType="Page">
<Setter Property="BackgroundColor" Value="{DynamicResource backgroundColor}" />
</Style>
<!--#endregion-->
<!--#region Frame-->
<Style x:Key="matCardStyle" TargetType="Frame">
<Setter Property="BackgroundColor" Value="White" />
<Setter Property="Margin" Value="0, 0, 0, 10" />
<Setter Property="CornerRadius" Value="2" />
</Style>
<Style x:Key="purpleAddButtonStyle" TargetType="Frame">
<Setter Property="BackgroundColor" Value="{DynamicResource purpleColor}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="CornerRadius" Value="15" />
<Setter Property="HeightRequest" Value="30" />
<Setter Property="WidthRequest" Value="30" />
<Setter Property="HasShadow" Value="False" />
</Style>
<Style x:Key="greenAddButtonStyle" TargetType="Frame" BasedOn="{StaticResource purpleAddButtonStyle}">
<Setter Property="BackgroundColor" Value="{DynamicResource greenColor}" />
</Style>
<Style x:Key="whiteDashboardButtonStyle" TargetType="Frame">
<Setter Property="BackgroundColor" Value="White" />
<Setter Property="Margin" Value="2" />
<Setter Property="Padding" Value="0" />
<Setter Property="CornerRadius" Value="5" />
<Setter Property="HeightRequest" Value="90" />
<Setter Property="WidthRequest" Value="90" />
<Setter Property="OutlineColor" Value="{DynamicResource seperatorColor}" />
<Setter Property="HasShadow" Value="False" />
</Style>
<!--#endregion-->
<!--#region Grid-->
<Style x:Key="gridStyle" TargetType="Grid">
<Setter Property="Padding" Value="20" />
</Style>
<Style x:Key="circleButtonGrid" TargetType="Grid">
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
<!--#endregion-->
<!--#region Label-->
<Style x:Key="headerPageStyle" TargetType="Label">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="FontSize" Value="Medium" />
</Style>
<Style x:Key="matCardSubtitleStyle" TargetType="Label">
<Setter Property="FontSize" Value="Medium" />
<Setter Property="HorizontalTextAlignment" Value="Center" />
<Setter Property="VerticalTextAlignment" Value="Center" />
<Setter Property="HorizontalOptions" Value="StartAndExpand" />
</Style>
<OnPlatform x:Key="positioningPlaceholder" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="0,0,0,-10" />
<On Platform="UWP" Value="0,0,0,0" />
</OnPlatform>
<Style x:Key="placeholderStyle" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource placeholderColor}" />
<Setter Property="FontFamily" Value="{DynamicResource fontFamiliy}" />
<Setter Property="FontSize" Value="Small"/>
<Setter Property="Margin" Value="{DynamicResource positioningPlaceholder}" />
</Style>
<OnPlatform x:Key="placeholderStyleVisible" x:TypeArguments="x:Boolean">
<On Platform="iOS" Value="true" />
<On Platform="Android" Value="true" />
<On Platform="UWP" Value="false" />
</OnPlatform>
<Style x:Key="placeholderStylePicker" TargetType="Label" BasedOn="{StaticResource placeholderStyle}">
<Setter Property="IsVisible" Value="{DynamicResource placeholderStyleVisible}" />
</Style>
<Style x:Key="readOnlyTextStyle" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource textColor}"></Setter>
<Setter Property="FontFamily" Value="{DynamicResource fontFamiliy}" />
<Setter Property="FontSize" Value="Small" />
<Setter Property="Margin" Value="{DynamicResource positioningPlaceholder}" />
</Style>
<OnPlatform x:Key="positioningPlusText" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="-2, -12, -2, -12" />
<On Platform="UWP" Value="-5" />
</OnPlatform>
<Style x:Key="addButtonLabelStyle" TargetType="Label">
<Setter Property="Text" Value="+" />
<Setter Property="TextColor" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Margin" Value="-2, -12, -2, -12" />
</Style>
<OnPlatform x:Key="dashboardButtonLabelFontSize" x:TypeArguments="Font">
<On Platform="iOS" Value="Small" />
<On Platform="Android" Value="Small" />
<On Platform="UWP" Value="Micro" />
</OnPlatform>
<Style x:Key="dashboardButtonLabelStyle" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource textColor}" />
<Setter Property="FontSize" Value="{DynamicResource dashboardButtonLabelFontSize}" />
<Setter Property="Margin" Value="10,0,10,0" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="HorizontalTextAlignment" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
</Style>
<!--#endregion-->
<!--#region Entry-->
<OnPlatform x:Key="positioningEntry" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="-4,0,0,0" />
<On Platform="UWP" Value="0,0,0,0" />
</OnPlatform>
<Style x:Key="entryStyle" TargetType="Entry">
<Setter Property="Margin" Value="{DynamicResource positioningEntry}" />
<Setter Property="FontSize" Value="Small"/>
</Style>
<Style x:Key="entryStyleSmall" TargetType="Entry">
<Setter Property="Margin" Value="{DynamicResource positioningEntry}" />
<Setter Property="FontSize" Value="Micro"/>
</Style>
<!--#endregion-->
<!--#region Picker-->
<OnPlatform x:Key="positioningPicker" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="-5,0,0,0" />
<On Platform="UWP" Value="0,3,0,0" />
</OnPlatform>
<Style x:Key="pickerStyle" TargetType="Picker">
<Setter Property="FontSize" Value="Small"/>
<Setter Property="Margin" Value="{DynamicResource positioningPicker}" />
<Setter Property="TitleColor" Value="{DynamicResource placeholderColor}" />
</Style>
<!--#endregion-->
<!--#region Entry-->
<OnPlatform x:Key="positioningTimePicker" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="-4,0,0,0" />
<On Platform="UWP" Value="0,0,0,0" />
</OnPlatform>
<Style x:Key="timePickerStyle" TargetType="TimePicker">
<Setter Property="Margin" Value="{DynamicResource positioningEntry}" />
</Style>
<!--#endregion-->
<!--#region DatePicker-->
<OnPlatform x:Key="positioningDatePicker" x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,0,0,0" />
<On Platform="Android" Value="-5,0,0,0" />
<On Platform="UWP" Value="0,0,0,0" />
</OnPlatform>
<Style x:Key="datePickerStyle" TargetType="DatePicker">
<Setter Property="Margin" Value="{DynamicResource positioningDatePicker}" />
</Style>
<!--#endregion-->
<!--#region ListView-->
<Style x:Key="listViewStyle" TargetType="ListView">
<Setter Property="Margin" Value="5" />
<Setter Property="SeparatorColor" Value="{DynamicResource seperatorColor}" />
</Style>
<!--#endregion-->
</ResourceDictionary>
</Application.Resources>
Hey @negberts, this looks related to #8459. I think there is a workaround stated in there. Would you be able to try that and see if that works for the time being?
@jfversluis the workaround should be to add the part
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition=" $(TargetFramework.StartsWith('uap10.0')) ">
<Exec Command="XCOPY $(TargetDir)Microsoft.UI.Xaml $(TargetDir)$(ProjectName)\Microsoft.UI.Xaml\ /E /Y" />
<Exec Command="COPY $(TargetDir) $(TargetDir)$(ProjectName)" />
</Target>
to the shared library right? That did not fix it for me. Same error about the resource dictionary occured.
@negberts
Can you try adding
<GenerateLibraryLayout>true</GenerateLibraryLayout>
To your class library and see if that fixes?
@PureWeen no sorry. It doesn't fix it. I also tried to remove the complete dictionary from the app.xaml but even then the error occurs. Could it be some third party problem? That Xamarin Essentials, Xam.Plugin.Geolocator or Prism is doing something incompatible? (These are all up to date btw)
The issue still shows after 4.3-sr3 and 4.4-pre3.
This makes 4.3 unusable in UWP.
Why is it marked as "unverified"?
What needs to be verified?
@JunielKatarn a repro where we can see it crash so that we can try to fix or guide
For example I took the Xaminals project here https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/Xaminals, added a UWP project to it, updated to 4.4 pre3, and deployed it with a release configuration with no issues
There are a lot of different possible configurations your project could have that's causing this issue so once we can recreate then we can mark as verified/regression and fix
@JunielKatarn @negberts
If you try some of the things mentioned in these comments does it fix?
https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/2681#issuecomment-441323375
Or possibly this is your explanation?
https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/1855#issuecomment-369442605
I was seeing this exception as well when messing around with some multi targeting and was able to fix by matching my target too my development machine
@PureWeen I am already at target version 18362 which is the latest I believe...
Or possibly this is your explanation?
windows-toolkit/WindowsCommunityToolkit#1855 (comment)
I was seeing this exception as well when messing around with some multi targeting and was able to fix by matching my target too my development machine
I'm afraid none of those links seem to apply.
I'm using a dev machine with Windows Version 10.0.18362 Build 18362.
That is exactly the same Windows SDK version the app targets: 10.0.18362.0.
Regarding using 17134 or below, it does not make sense, because if I instead downgrade Xamarin.Forms from 4.3.x to 4.2.x, it works fine.
Thus, the bug is either in or uncovered by version 4.3.
For reference, I encounter it deterministically while running this GitHub project (which I manage):
https://github.com/hyvart/Unjammit
I have created an experimental branch, on which I'll gradually strip (comment-out) app functionality until it's equivalent to a blank Xamarin/UWP app.
https://github.com/hyvart/Unjammit/tree/Xamarin.Forms/GH/8649
@JunielKatarn I pulled down https://github.com/hyvart/Unjammit and it ran fine for me
do I need to click something?
@JunielKatarn I pulled down https://github.com/hyvart/Unjammit and it ran fine for me
do I need to click something?
Interesting.
No, if the app started up fine, you should be good.
I keep encountering the crash when building the Release configuration.
I have tested this in four fairly different computers.
What Windows version are you running?
Also, what Visual Studio version? I’m using 15.3.10.
If you add this nuget to your uwp project does that fix?
https://www.nuget.org/packages/Microsoft.UI.Xaml/2.1.190606001
If you add this nuget to your uwp project does that fix?
https://www.nuget.org/packages/Microsoft.UI.Xaml/2.1.190606001
That worked! I’ll double-check in the other machines, but pretty confident that was it.
Note, I actually installed version 2.3.x (latest).
Is there a reason I should use 2.1.190606001 instead?
@JunielKatarn That's 2.1 is just the version we've tested with so figured I'd start there.
If 2.3 works for you though 👍
Glad to see that worked. There's some transitive updates to nuget that aren't part of VS 15. I'm guessing that's why you are having issues there.
@PureWeen it did not fix my problem… Do I have to add the Microsoft.UI.Xaml package to both the shared library and the UWP project or only the UWP project?
Upgrading to 2.3 instead of 2.1 fixed it for me too.