XAML Custom base page not working - Can't load types

LudovicThomasLudovicThomas ✭✭USMember ✭✭

I have an issue trying to create a custom MyBasePage that will deal with some key behavior for all pages of the app.
For that, I have created a class "MyBasePage" that inherits from "ContentPage" in the namespace "MyProject.Pages.Generic".
And I try to create a new page "TempPage" in XAML. I have set the designer page inherits from "MyBasePage" class, and the issue is in the XAML using the "local"namespace.

<?xml version="1.0" encoding="UTF-8"?> <local:MyBasePage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyProject.Pages.TempPage" xmlns:local="clr-namespace:MyProject.Pages.Generic;assembly=MyProject"> </local:MyBasePage>

The error is
Error executing task XamlG: Can't load types from xmlns clr-namespace:MyProject.Pages.Generic;assembly=MyProject

Do you have any idea of the issue?


  • MihaMarkicMihaMarkic ✭✭✭✭ SI ✭✭✭✭

    Looks like a bug in latest version on Xamarin stable channel. It works with the latest version on Beta channel.

  • LudovicThomasLudovicThomas ✭✭ USMember ✭✭

    Thanks Miha. Will check this monday with either the beta channel, or the previous stable version and let you know.

  • StephaneDelcroixStephaneDelcroix ✭✭✭✭ USInsider, Beta ✭✭✭✭

    @LudovicThomas‌ this should work as is, unrelated of the version of Xamarin Studio you're running. The behavior depend only on the Xamarin.Forms version.

    Could you make sure you are using the latest stable nuget available (1.2.3) and report back ?

    Also, does the same xmlns:local definition works in other parts of your app ? if not, it could be just that, and the error message could be spot on.

  • MihaMarkicMihaMarkic ✭✭✭✭ SI ✭✭✭✭
    edited October 2014

    @StephaneDelcroix‌ I'm pretty sure it was caused by the Xamarin stack somewhere, not Forms (or perhaps the combination of the two). I tried an existing project and got compilation time error. When I updated Xamarin stack to latest beta it started working again. Without changing Forms version that is. Of course, I could have made a mistake somewhere... The Forms version was pre 1.2.3.

  • LudovicThomasLudovicThomas ✭✭ USMember ✭✭

    @StephaneDelcroix‌ Yes I'm using the latest stable version 1.2.3.
    Finally, it's working back... After testing the "XAMLSamples" this morning, to test local XAML views (with local:ClockViewModel), I switch back to my test project, and everything was working smoothly.
    Sometimes, a complet clean of the solution can be a good way to solve issues. I will remember that.

    Thanks for your quick reply, and sorry for the bad report.

  • jonathanyatesjonathanyates ✭✭✭ GBMember ✭✭✭

    This is still is not fixed on on stable using osx Xamarin Studio.

    To Replicate,
    1. Create a new PCL app. (named it ErrorSpike)
    2. Add a new Class Library (Portable) to the solution. (named it Shared)
    3. Create a class in Shared (named CustomPage) and inherit this from Page.
    4. Create a new ContentPage in the applications PCL project called MainPage.
    5. Inherit this page from CustomPage in the code behind and update the Xaml as follows:

    <?xml version="1.0" encoding="UTF-8"?>


    1. Build Solution.

    2 Errors reported:

    MainPage.xaml: Error: Error executing task XamlG: Can't load types from xmlns clr-namespace:Shared;assembly=Shared

    /Users/Administrator/Projects/ErrorSpike/packages/Xamarin.Forms. Error: Error executing task XamlG: Can't load types from xmlns clr-namespace:Shared;assembly=Shared (ErrorSpike)

  • jonathanyatesjonathanyates ✭✭✭ GBMember ✭✭✭

    Also get an error reported in xaml editor if I simply reference an other PCL class library.

    /Users/Administrator/Projects/ErrorSpike/ErrorSpike/Views/MainPage.xaml(7,7): Error: The type or namespace name `Shared' could not be found. Are you missing an assembly reference? (ErrorSpike)

    All I needed to do to replicate this was to create MainPage as a Normal ContentPage without deriving from a custom Page. Then add a reference to my shared class library. Add a using statement for Shared anywhere in the project. Then edit the MainPage.Xaml. Anything will do, just a label or something, doesn't matter. Build, Error reported in xaml in big Red error message. (Screenshot attached).

    Anyone any idea's what's going on here as it is very very annoying.

Sign In or Register to comment.