locked
Assembly for xmlns:locate not found (Forms-Project with XAML) RRS feed

  • Question

  • User84220 posted

    Hi,

    in my Shared-Forms-Project "BorrowedBooks" this "MainPage" made in XAML should dislpay a list of books. The list is a static member in App.cs

    <?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:local="clr-namespace:BorrowedBooks;assembly=BorrowedBooks"
                           x:Class="BorrowedBooks.Views.MainPage"
                           Title="Borrowed Books">
        <ListView x:Name="listView" IsVisible="true" ItemsSource="{x:Static local:App.BorrowedBooks}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand">
                                <Label Text="{Binding Name}" HorizontalOptions="Center" />
                                <Label Text="{Binding Author}" Font="10" HorizontalOptions="Center"/>
                            </StackLayout>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage>
    

    The problematic point is following line:
    xmlns:local="clr-namespace:BorrowedBooks;assembly=BorrowedBooks"
    If I debug the App on any platform (WinPhone, Android), an IOExpection occurs and tells me that the assembly "BorrowedBooks" was not found.
    If I run it on Anroid and change the code like this, then it works perfetly:
    xmlns:local="clr-namespace:BorrowedBooks;assembly=BorrowedBooks.Android"
    The same works analog with "WinPhone", but I think this should work without the platform specific name?

    I'm using Visual Studio 2013 Update 3 and the current Xamarin version.

    Tuesday, November 4, 2014 7:38 PM

All replies

  • User181 posted

    Check your assembly name in your project file. It should match.

    Tuesday, November 4, 2014 7:42 PM
  • User84220 posted

    Thanks for the quick answer.
    I'm not quite sure which project file you meant. I've attached the project structre as picture.
    The "MainPage" is located in the Shared Project which hasn't a own assembly, has it?
    The Assembly from the Android Project is named "BorrowedBooks.Android" and from the WinPhone Project "BorrowedBooks.WinPhone"

    Tuesday, November 4, 2014 8:11 PM
  • User181 posted

    Whichever one has the class you're trying to use.

    Tuesday, November 4, 2014 8:13 PM
  • User84220 posted

    I need the "xmlns:local-namespace" to get access to the list of books from App.cs, but this is all part of the Shared-Project.
    So I only need classes from the Shared-Project. But if I have understood you right, I have to declare the absolute name of the platform I run the App. This would be platform-specific code in the Shared-Code which doesn't make sense to me, because it doesn't work for the other platforms which are also using the Shared-Project.

    Tuesday, November 4, 2014 8:35 PM
  • User181 posted

    No, I'm not saying change the XML. I'm saying change the project file so that your assembly has the same name on all platforms. Maybe BorrowedBooks.Platform?

    Tuesday, November 4, 2014 8:44 PM
  • User84220 posted

    Thanks, that works for me :)

    Tuesday, November 4, 2014 8:53 PM
  • User74110 posted

    I've also run into this issue using a shared project, and was disappointed to find that using the same name for each of the platform project assemblies was the only solution.

    I was reading here that Xaml can infer the current assembly if you don't specify the name of an assembly in the xmlns definition. In my Forms project, however, I get a null reference when I try this.

    Is inferring the current assembly by omitting "assembly=[your-assembly-name]" not supported in the Forms version of Xaml? I'd say this is a frustrating deficit. Anyone file a bug yet?

    Friday, December 5, 2014 6:43 PM
  • User140120 posted

    Hi @Rainer Oechsle where you change the code or assembly because I am also getting the same reference error.What is project file in the project can you give me the path where I can find it ?????

    Wednesday, September 23, 2015 8:56 AM
  • User280967 posted

    Hi @vikramboya - You need to go to Project -> Assembly, and change the name there

    Sunday, January 22, 2017 5:34 PM
  • User1004 posted

    If you are referring to the current assembly, you can skip the assembly=... part so it will resolve whatever the actual name of the assembly is.

    If it's not the current assembly, you have to use the full assembly name. If you're using shared assets projects, you should make sure all of your projects share the same name.

    This is one of the reason why we advice against using sharing assets projects...

    Sunday, January 22, 2017 8:34 PM
  • User130923 posted

    Yes, it worked for me. Thanks @StephaneDelcroix

    Tuesday, July 4, 2017 3:20 PM