Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Customer renderer not being found (Object type .. cannot be converted to target type: Xamarin.Forms)

$
0
0

I've been trying to create a custom renderer as described here. I'm getting the following error and have had no luck in determining why:

System.ArgumentException: Object type iOSForms.VideoLayoutManager cannot be converted to target type: Xamarin.Forms.View

This seems strange because my iOS project is providing an implementation that is a Xamarin.Forms.View (iOSForms is the PCL's namespace and iOS is the iOS project's namespace):

[assembly: ExportRenderer(typeof(iOSForms.VideoLayoutManager), typeof(iOS.iOSVideoLayoutManager))]
namespace iOS
{
    public class iOSVideoLayoutManager : View
    {
    }
}

I've also tried extending other classes, like the EntryRenderer that the examples use.

And then iOSForms.VideoLayoutManager (which is in a PCL) is defined as simply:

namespace iOSForms
{
    public class VideoLayoutManager {}
}

Exactly as the documentation demonstrates. I even tried making it extend View, but that gets the error "System.InvalidCastException: Cannot cast from source type to destination type."

My XAML file is simply:

<?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:iOSForms;assembly=iOSForms"
             x:Class="iOSForms.VideoPage">
    <StackLayout>
        <local:VideoLayoutManager />
    </StackLayout>
</ContentPage>

The error message seems to imply that the iOS custom renderer isn't being used and that Xamarin.Forms is trying to use the VideoLayoutManager, which obviously is not a View. So what am I doing wrong?


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>