Getting Argument Cannot Be Null Parameter name: assemblyName XAML

RaymondKellyRaymondKelly USMember ✭✭✭
edited June 2015 in Xamarin.Forms

I just cannot figure this out. I am trying to use a converter for a StaticResource call. On app startup I get the error Argument Cannot Be Null Parameter name: assemblyName XAML. Here is what I have.

Converter Class:

using System;
using System.Globalization;
using System.IO;
using Xamarin.Forms;

namespace MyApp.Converters
{

public class ByteArrayToImageSourceConverter : IValueConverter
{ 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null)
        {
            return null;
        }
        byte[] bytes = value as byte[];
        return ImageSource.FromStream(() => new MemoryStream(bytes));
    }
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

}

And in my 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:converters="clr-namespace:MyApp.Converters; assembly=MyApp" x:Class="MyApp.FriendsForm"> <ContentPage.Resources> <ResourceDictionary> <converters:ByteArrayToImageSourceConverter x:Key="bytesToImage"></converters:ByteArrayToImageSourceConverter> </ResourceDictionary> </ContentPage.Resources> <ContentPage.Content> <ListView x:Name="listView"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> ..............

Even before calling the function I get the above error when starting the app up. It seems related to the namespaces or xmlns but I just cant figure it out. Thank you for your help!

Posts

  • AndrewMobileAndrewMobile USMember ✭✭✭✭
    edited June 2015

    remove the space after semicolon and before 'assembly':
    xmlns:converters="clr-namespace:MyApp.Converters;assembly=MyApp"

  • RaymondKellyRaymondKelly USMember ✭✭✭

    Wow, that was literally 4 hours of hair pulling. Thank you kind sir.

  • PaulNPaulN USMember ✭✭

    I've also got this error when I've omitted "assembly=MyApp" section of namespace declaration. So assembly part is mandatory when you trying to define resource in dictionary.

Sign In or Register to comment.