We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

System.TypeInitializationException trying to change Getting Started Example

Thread ID:





128820 Feb 10,2017 09:33 PM UTC Feb 15,2017 02:34 PM UTC Xamarin.Forms 3
Tags: SfChart
Fabrizio Frigerio
Asked On February 10, 2017 09:33 PM UTC

I've tried Getting Started Example and it works fine but is too simple so i've tried to change the code to see if your control can be used in my new project.
I'm new to Xamarin.Forms so I've started step by step. First I've tried to use the DLL's installed by the trial version of Syncfusion Essential Studio because the one's shipped with the demo package seem not to handle a collection of custom objects for the series ItemSource as explained here but I'm stuck, the simple code:

SfChart chart = new SfChart();

is now raising the exception "System.TypeInitializationException: The type initializer for 'Syncfusion.SfChart.XForms.SfChart' threw an exception".

Any ideas?

Thanks in advance

Parthiban Sundaram [Syncfusion]
Replied On February 13, 2017 12:35 PM UTC

Hi Fabrizio,

Sorry for the inconvenience caused.

You can refer the below link for updated sample on getting started with SfChart. We kindly request you to rebuild the application and check if the issue still exists.

Sample: http://www.syncfusion.com/downloads/support/forum/128820/ze/Chart_GettingStarted-477584956  

Please refer the following UG link for more details.

Link : https://help.syncfusion.com/xamarin/sfchart/getting-started  

If you still facing any issues, please update us the modified sample similar to your requirement which will be helpful for providing further assistance.

Parthiban S 

Fabrizio Frigerio
Replied On February 14, 2017 11:00 AM UTC

Hi Parthiban,

I've tried the new sample and it works despite some issues with Nuget packages not updating. In the sample all the binding was performed in Xaml but I need to set and change bindings in code behind. I've tried to move the xaml code into the cs file but seem to be impossible to add series in code behind, or rather are added but not plotted. I've added a zip file with all the files I've changed in the example. 
This code;

            Chart.Series.Add(new SplineSeries()
                ItemsSource = "{Binding Data}",
                YAxis = YAxis_Right,
                XBindingPath = "Name",
                YBindingPath = "Age",
                Color = Color.Green,
                Label = "Age"

does not plot the series, I had to define the series in xaml like this 

        <chart:SplineSeries ItemsSource="{Binding Data}" Label="Heights" XBindingPath="Name" YBindingPath="Height" EnableTooltip="True">
        <chart:SplineSeries ItemsSource="{Binding Data}" Label="Ages" XBindingPath="Name" YBindingPath="Age" EnableTooltip="True">

and then change what I need in code bihind like this:

            SplineSeries serie = (SplineSeries)Chart.Series[0];

            //serie.YBindingPath = "Age";
            serie.Color = Color.Aqua;

            serie = (SplineSeries)Chart.Series[1];
            serie.YAxis = YAxis_Right;
            serie.Color = Color.Green;

Thanks for the support.

Attachment: ChartSample_7860bde4.zip

Parthiban Sundaram [Syncfusion]
Replied On February 15, 2017 02:34 PM UTC

Hi Fabrizio,

Thanks for the update.

We have modified the sample based on your requirement. Please download the sample from following location.

Sample: http://www.syncfusion.com/downloads/support/forum/128820/ze/SimpleSample-396999530  

Please let us know, if you need further assistance on this.

Parthiban S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon