0
votes

When I try to insert a BoxView with a GradientBackground this exception is thrown. In the c # code I have inserted the Flag, but it is not enough. How could I solve?

System.TypeLoadException: 'Could not resolve type with token 0100009c from typeref (expected class 'Xamarin.Forms.GradientStop' in assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null')'

XAML code

<BoxView>
      <BoxView.Background>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
               <GradientStop Color="Gray" Offset="0" />
               <GradientStop Color="Transparent" Offset="1.0" />
          </LinearGradientBrush>
     </BoxView.Background>
</BoxView>

c# code

     public MainPage()
    {
        InitializeComponent();
        Device.SetFlags(new[] { "Brush_Experimental" });
    }
1
call SetFlags in your App class, not your PageJason
keep giving me the errorStefano Ston

1 Answers

0
votes

Firstly, you should set flags in your App class or AppDelegate/MainActivity respectively.

(Official Documentation on Flags and how to opt in)

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/experimental-flags

Try updating your Xamarin.Forms NuGet package in the package manager, an older version has often been the cause of similar problems for me.

Also try cleaning and rebuilding your solution. I have created a video on how to opt in to Xamarin Experimental features, if all else fails try watching it and catching a difference between your project and my sample project: https://www.youtube.com/watch?v=W008ZlCjEZ8