How to fix exception System.TypeLoadException: VTable setup of type Xfx.Controls.Droid.Renderers.Xfx

judsonabrahamjudsonabraham USMember ✭✭✭

I'm trying to implement XfxCardView in my Xamarin Forms app. The exception occurs when the app is loading. There is no error while building. I don't know why I'm getting this exception. The exception is

Unhandled Exception:

System.TypeLoadException: VTable setup of type Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid failed

This is my XAML code

<?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:xfx="clr-namespace:Xfx;assembly=Xfx.Controls"

             x:Class="ScrollerSample.Gallery" BackgroundColor="White">
    <StackLayout Margin="20,0,0,0">
        <Label  Text="Top specialitiest" TextColor="Black" FontFamily="Bold,10"  FontSize="20" />


    <Grid RowSpacing="0">
    <Grid.RowDefinitions >
      <RowDefinition Height="*"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>
    <ScrollView Grid.Row="0" HorizontalOptions="FillAndExpand" Orientation="Horizontal" VerticalOptions="StartAndExpand">
                <StackLayout   x:Name="StackGallery" Padding="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand">

                </StackLayout>
    </ScrollView>
            <Label Grid.Row="1" Text="RESTAURANTS NEAR YOU" TextColor="#595959" HeightRequest="30"></Label>
            <Label Grid.Row="2" Text="25 Restaurants finded" TextColor="#d9d9d9" HeightRequest="20"></Label>

        </Grid>
        <StackLayout>

            <xfx:XfxCardView CornerRadius="3" Elevation="3">
                <StackLayout Padding="0" Margin="0">
                    <Image Source="http://lorempixel.com/1024/200/abstract" HorizontalOptions="Fill" Aspect="Fill" />
                    <Label Text="hi judson" TextColor="Black" Margin="8"/>



                </StackLayout>
            </xfx:XfxCardView>
        </StackLayout>
    </StackLayout>

</ContentPage>

This is the code in MainActivity

    using Xfx;

    namespace ScrollerSample.Droid
    {
        [Activity(Label = "ScrollerSample", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
        public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
        {
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                XfxControls.Init();
                global::Xamarin.Forms.Forms.Init(this, bundle);
                LoadApplication(new App());
            }
        }
    }

I have added all the necessary codes required for displaying the card view but I'm still getting the exception.

Best Answer

Answers

Sign In or Register to comment.