ios developer
ios developer

Reputation: 3473

Xamarin.Forms.Xaml.XamlParseException exception in Xamarineforms

I am new to Xamarine. I had created new blank Xamarine project in Visual studio 2019. I am using this link to create demo native views in Xamarine forms : https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/native-views/xaml

MainPage.Xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:ios="clr-namespace:UIKit;assembly=Xamarin.iOS;targetPlatform=iOS"
             xmlns:androidWidget="clr-namespace:Android.Widget;assembly=Mono.Android;targetPlatform=Android"
             xmlns:androidLocal="clr-namespace:App1.Android;assembly=App1.Android;targetPlatform=Android"
             mc:Ignorable="d"
             x:Class="App1.MainPage">
    <StackLayout>
        <!-- Place new controls here -->
        <ios:UILabel Text="Hello World" TextColor="{x:Static ios:UIColor.Red}" View.HorizontalOptions="Start" />
        <androidWidget:TextView Text="Hello World" x:Arguments="{x:Static androidLocal:MainActivity.Instance}" />
    </StackLayout>
</ContentPage>

I had added skip Xamlcomplitation in MainPage.xaml.cs file.

[XamlCompilation(XamlCompilationOptions.Skip)]

Added in MainActivity.cs in App1.Android file.

internal static MainActivity Instance { get; private set; } // define Instance

enter image description here

Bit it shows error for

 ( 8976): Assembly Ref addref System.Xml[0xd1e768c0] -> System[0xe4b32b00]: 5
**Xamarin.Forms.Xaml.XamlParseException:** 'Position 15:52. Type MainActivity not found in xmlns clr-namespace:App1.Android;assembly=App1.Android;targetPlatform=Android'

Upvotes: 0

Views: 260

Answers (1)

Ivan I
Ivan I

Reputation: 9990

[XamlCompilation(XamlCompilationOptions.Skip)]

Is something that you add to the Xaml backend code. Adding it to something else like in your case is likely to cause problems.

Upvotes: 2

Related Questions