XAML compile-time checking problem

In order to ensure compile-time checking of all XAML, I added the following to our App.xaml.cs:

using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

namespace MyApp
{ ...

When I build the app, I get the following error message:

Resource: MyApp.App.xaml...
Parsing Xaml... done.
Replacing App.InitializeComponent ()... failed.
MyApp.App.xaml: error : The given key was not present in the dictionary.

Any idea what the problem can be?
(The app builds and runs fine without compile-checking of XAML)

Answers

  • HunumanHunuman GBMember ✭✭✭✭

    The only time I have had similar messages, is when I've incorrectly set a property attribute in my XAML.

  • HrafnLoftssonHrafnLoftsson ISMember ✭✭

    Solved by replacing
    <system:String x:Key="something">constant</system:String>

    in App.xaml with

    <x:String x:Key="something">constant</x:String>

    where x comes from

    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

  • HunumanHunuman GBMember ✭✭✭✭

    Cool, glad you sorted it.
    XAML error messages are a bit vague IMO, but could be worse I suppose.

  • Zafar.4544Zafar.4544 USMember ✭✭

    I too have the similar issue, but I don't have App.xaml file. I have App.cs file instead in my project. When I did the file search in the solution folder, I see some App.xaml (inside components folder or nuget package folders) files which does not have tag anywhere. Any Idea how to fix it?

  • HunumanHunuman GBMember ✭✭✭✭

    @Zafar.4544

    Please post the text of the error message.

    Tim

  • AngelRAngelR USMember

    @HrafnLoftsson said:
    Solved by replacing
    <system:String x:Key="something">constant</system:String>

    in App.xaml with

    <x:String x:Key="something">constant</x:String>

    where x comes from

    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

    Thx @HrafnLoftsson

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    what's your system xmlns definition ?

  • HrafnLoftssonHrafnLoftsson ISMember ✭✭

    I don't have a system xmlns definition.

Sign In or Register to comment.