microcharts - missing method exception

Anurag Kumar 1 Reputation point
2020-12-31T00:18:59.46+00:00

I am trying to add a simple chart to my Xamarin Cross platform application but get below error when running in android emulator (Android 9.0 - API 28)

Unhandled Exception:

System.MissingMethodException: Method not found: !0& System.ReadOnlySpan`1.GetPinnableReference()


I am following steps as mentioned in follow video: https://www.youtube.com/watch?v=tmymWdmf1y4


MainPage.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:local="clr-namespace:MicroChartsDemo"
             xmlns:forms="clr-namespace:Microcharts.Forms;assembly=Microcharts.Forms"
             x:Class="MicroChartsDemo.MainPage">

    <forms:ChartView Grid.Row="1" x:Name="Chart1" HeightRequest="150"/>

</ContentPage>

MainPage.xaml.cs code

public partial class MainPage : ContentPage
    {
        List<ChartEntry> entries = new List<ChartEntry>
        {
            new ChartEntry(200)
            {
                Color = SKColor.Parse("#FF1493"),
                Label = "January",
                ValueLabel = "200"
            },
            new ChartEntry(400)
            {
                Color = SKColor.Parse("#00BFFF"),
                Label = "February",
                ValueLabel = "400"
            },
            new ChartEntry(-100)
            {
                Color = SKColor.Parse("#00CED1"),
                Label = "March",
                ValueLabel = "-100"
            }
        };
        public MainPage()
        {
            InitializeComponent();

            Chart1.Chart = new RadialGaugeChart { Entries = entries };
        }
    }

All Nuget packages are latest build:

Microcharts.Forms - v0.9.5.9
NETStandard.Library - v2.0.3
Xamarin.Android.Support (Design, v4, v7.AppCompat, v7.CardView, v7.MediaRouter) - v28.0.0.3
Xamarin.Forms - v4.8.0.1821
SkiaSharp, SkiaShard.Views and Views.Forms - v2.80.2

The steps I did was basically - create crossplatform -> Movile App (XamarinForms) project - Blacnk App with .Net Standard as code sharing strategy
Then I updated all Nuget packages
Added Microcharts Nuget package
Got the error
Added SkiaSharp Nuget package
Still getting error

What am I doing wrong?

Thanks,
Anurag Kumar

Developer technologies | .NET | Xamarin
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-01-01T02:38:51.553+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    @Anurag Kumar You can try to use Oxyplot to draw a chart

    https://oxyplot.readthedocs.io/en/latest/getting-started/hello-xamarin-forms.html

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.