如何修复异常 System.TypeLoadException:类型 Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid 的 VTable 设置失败
How to fix exception System.TypeLoadException: VTable setup of type Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid failed
我正在尝试在我的 Xamarin Forms 应用程序中实现 XfxCardView。加载应用程序时发生异常。构建时没有错误。我不知道为什么我会得到这个例外。例外是
Unhandled Exception:
System.TypeLoadException: VTable setup of type Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid failed
这是我的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: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>
这是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());
}
}
}
我已经添加了显示卡片视图所需的所有必要代码,但我仍然遇到异常。我正在使用 this Link 进行卡片查看。
UPADTE:对我来说,这是由 Xamarin Forms Nuget 包 3.3.0.967582 -> 3.4.0.10008975 引起的。还原此包会删除异常。
这不是答案,而是评论(带图片),因为我无法在评论中添加图片。
我也遇到了这个问题。它从今天开始,当时我更新了所有 Nugets。不确定是哪个更新引起的,但这里是更新的包。
我会报告任何新发现。
我正在尝试在我的 Xamarin Forms 应用程序中实现 XfxCardView。加载应用程序时发生异常。构建时没有错误。我不知道为什么我会得到这个例外。例外是
Unhandled Exception:
System.TypeLoadException: VTable setup of type Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid failed
这是我的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: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>
这是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());
}
}
}
我已经添加了显示卡片视图所需的所有必要代码,但我仍然遇到异常。我正在使用 this Link 进行卡片查看。
UPADTE:对我来说,这是由 Xamarin Forms Nuget 包 3.3.0.967582 -> 3.4.0.10008975 引起的。还原此包会删除异常。
这不是答案,而是评论(带图片),因为我无法在评论中添加图片。
我也遇到了这个问题。它从今天开始,当时我更新了所有 Nugets。不确定是哪个更新引起的,但这里是更新的包。
我会报告任何新发现。