locked
Duplicate Xaml Compilation Attribute error RRS feed

  • Question

  • User382837 posted

    Hello, I added the following code in my code "[assembly: XamlCompilation(XamlCompilationOptions.Compile)]" and I get the duplicate Xaml Compilation Attribute error. Any reason why?

     using Xamarin.Forms.Xaml;
    
     [assembly: XamlCompilation(XamlCompilationOptions.Compile)]
    
     namespace QuickFlicks
     {
         public partial class MainPage : ContentPage
         {
             public MainPage()
             {
                 InitializeComponent();
             }
         }
     }
    
    Saturday, March 23, 2019 6:54 AM

Answers

  • User382871 posted

    Compilation has been declared in App.xaml.cs . It's unnecessary to declare in page.xaml.cs. If you just want to declare the compilation in page.xaml, comment the declaration in App.xaml.cs. ``` [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace App_test { public partial class App : Application { public App() { InitializeComponent();

            MainPage = new MainPage();
        }
    ...
    }
    

    } ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, March 25, 2019 7:53 AM

All replies

  • User382871 posted

    Compilation has been declared in App.xaml.cs . It's unnecessary to declare in page.xaml.cs. If you just want to declare the compilation in page.xaml, comment the declaration in App.xaml.cs. ``` [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace App_test { public partial class App : Application { public App() { InitializeComponent();

            MainPage = new MainPage();
        }
    ...
    }
    

    } ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, March 25, 2019 7:53 AM
  • User391065 posted

    For those of you using the newer project templates it's now declared in AssemblyInfo.cs.

    AssemblyInfo.cs

    ```CSharp using System.Resources; using Xamarin.Forms.Xaml;

    [assembly: XamlCompilation(XamlCompilationOptions.Compile)] [assembly: NeutralResourcesLanguage("en-US")] ```

    Tuesday, January 21, 2020 3:50 PM