How to debug: Xamarin.Forms.Xaml.XamlParseException: Cannot assign property "Content"

Trying to create a basic CRUD app based on the Todo sample from Xamarin university using Net Standard & Android.
When deploying to Android, I get the following error:

Xamarin.Forms.Xaml.XamlParseException: Cannot assign property "Content": Property does not exists, or is not assignable, or mismatching type between >value and property

On this line of MainPage.xaml.g.cs:

global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(MainPage));

There are no build errors when I do a Build without a deploy.

Some of the output from Debug window is below:

12-22 12:34:51.960 D/Mono ( 9391): Assembly System.ComponentModel[0x7f6ef44e00] added to domain RootDomain, ref_count=1
12-22 12:34:51.964 D/Mono ( 9391): AOT: image 'System.ComponentModel.dll.so' not found: dlopen failed: library "/data/app/com.companyname.Tallyv01-1/lib/arm64/libaot-System.ComponentModel.dll.so" not found
12-22 12:34:51.967 D/Mono ( 9391): AOT: image '/usr/local/lib/mono/aot-cache/arm64/System.ComponentModel.dll.so' not found: dlopen failed: library >"/data/app/com.companyname.Tallyv01-1/lib/arm64/libaot-System.ComponentModel.dll.so" not found
12-22 12:34:51.968 D/Mono ( 9391): Config attempting to parse: 'System.ComponentModel.dll.config'.
12-22 12:34:51.968 D/Mono ( 9391): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.ComponentModel/System.ComponentModel.config'.
12-22 12:34:51.968 D/Mono ( 9391): Assembly Ref addref Xamarin.Forms.Xaml[0x7f84957e00] -> System.ComponentModel[0x7f6ef44e00]: 2
12-22 12:34:51.968 D/Mono ( 9391): Assembly Ref addref System.ComponentModel[0x7f6ef44e00] -> mscorlib[0x7f8769cb00]: 51
Loaded assembly: System.ComponentModel.dll [External]
12-22 12:34:51.983 D/Mono ( 9391): Assembly Ref addref Xamarin.Forms.Core[0x7f84957080] -> System.ComponentModel[0x7f6ef44e00]: 3
12-22 12:34:51.997 D/Mono ( 9391): Assembly Ref addref Xamarin.Forms.Xaml[0x7f84957e00] -> System.Reflection.Extensions[0x7f6f6ef100]: 4
12-22 12:34:52.085 D/Mono ( 9391): Assembly Ref addref System.Collections[0x7f84962580] -> System.Core[0x7f84962e00]: 6
12-22 12:34:52.085 D/Mono ( 9391): Assembly Ref addref System.Core[0x7f84962e00] -> System[0x7f6f4de580]: 9
12-22 12:34:52.782 D/Mono ( 9391): Assembly Ref addref netstandard[0x7f6f553500] -> System[0x7f6f4de580]: 10
Unhandled Exception:

Xamarin.Forms.Xaml.XamlParseException: Cannot assign property "Content": Property does not exists, or is not assignable, or mismatching type between value and property

MainPage.xaml

'<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.ToolbarItems>

<ToolbarItem.Icon>



</ToolbarItem.Icon>

</ContentPage.ToolbarItems>

<ListView.ItemTemplate>



                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

'

Thank you very much. I don't know what to do.

NOTE: Forum will not allow me to post links

Answers

  • DanielVidalesDanielVidales USMember ✭✭
    edited July 2018

    For any one with this problem, this is again a problem of having a Shared Project XAML with a Build Action other than Embedded Resource. Just to provide some detail about this particular setting: Layout resources which define the screens or pages for each platform (XMLs for Android, XIBs for IOS and XAML for UWP) are nothing but embedded resources from the perspective of each of these platform's projects. When using Xamarin Forms, these layout resources will be generated on compilation time, based on what's is defined in the Shared Project XAML, therefore the need to set the Build Action to Embedded Resource.

  • DanielVidalesDanielVidales USMember ✭✭

    Hello my friend, I was struggling with this for hours, and even knowing that XamlParseExceptions are due to syntacticall errors on the XAML most of the time and even though, I was looking carefully, for hours and wearing my glasses, I still missed an extraneous single quote on my XAML. So make sure that between elements there are not any characters as this might lead to the exception you mentioned. i.e
    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="../2014/forms"
    xmlns:x="..2009/xaml"

    '

    <ContentPage.Content>
    The single quote right next to ContentPage (in bold) will invalidate the complete XAML, however you will find about this on Runtime only, as it will compile with or without the single quote.

Sign In or Register to comment.