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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Empty SfChart crashes on Android: specified cast is not valid

Thread ID:

Created:

Updated:

Platform:

Replies:

132973 Oct 2,2017 05:28 AM UTC Oct 16,2018 07:12 AM UTC Xamarin.Forms 7
loading
Tags: SfChart
Gianluca Esposito
Asked On October 2, 2017 05:28 AM UTC

I'm using a SfChart control in my Xamarin Forms project (release 15.3.0.33 with Xamarin.Forms 2.4.0.282).
Just using an empty SfChart control it crashes during BaseInitialize as shown in stack trace.
Any suggestions?
Specified cast is not valid.
  • 1
    SfChart.BaseInitialize ()
  • 2
    ChartBase.Initialize ()
  • 3
    Com.Syncfusion.Charts.ChartBase..ctor (Android.Content.Context context) [0x0001a] in <35869240bce84637ac78aeb02a512071>:0
  • 4
    Com.Syncfusion.Charts.SfChart..ctor (Android.Content.Context context) [0x00000] in <35869240bce84637ac78aeb02a512071>:0
  • 5
    Syncfusion.SfChart.XForms.Droid.SfChartExt..ctor (Android.Content.Context context) [0x00000] in <35869240bce84637ac78aeb02a512071>:0
  • 6
    SfChartRenderer.GetNativeChart (Syncfusion.SfChart.XForms.SfChart sfChart)
  • 7
    SfChartRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e)
  • 8
    VisualElementRenderer`1[TElement].SetElement (TElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:171
  • 9
    IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:120
  • 10
    Platform.CreateRenderer (Xamarin.Forms.VisualElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:285
  • 11
    VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:86
  • 12
    VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:219
  • 13
    VisualElementPackager.Load () C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:70
  • 14
    VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:371
  • 15
    VisualElementRenderer`1[TElement].SetElement (TElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:174
  • 16
    IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:120
  • 17
    Platform.CreateRenderer (Xamarin.Forms.VisualElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:285
  • 18
    VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:86
  • 19
    VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:219
  • 20
    VisualElementPackager.Load () C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:70
  • 21
    VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:371
  • 22
    VisualElementRenderer`1[TElement].SetElement (TElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:174
  • 23
    IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:120
  • 24
    Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:322
  • 25
    FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:67
  • 26
    Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState)
  • 27
    (wrapper dynamic-method) System.Object:0dfcc65f-a4a6-4efb-b62e-de762ac1b4f4 (intptr,intptr,intptr,intptr,intptr)

Parthiban Sundaram [Syncfusion]
Replied On October 3, 2017 04:35 AM UTC

Hi Gianluca,

Sorry for the inconvenience caused.

Due to internal architecture change, now, it is not required to add Syncfusion.SfChart.Android.dll and Syncfusion.SfChart.iOS.dll assemblies to your platform specific projects such as Android and iOS in Xamarin.Forms respectively. Hence, you need to remove these two assemblies from your platform specific projects.

Please make sure that the following highlighted SfChart assemblies are only referred in your application.

 

Release notes: https://help.syncfusion.com/xamarin/release-notes/v15.3.0.26?type=all#breaking-changes  

UG: https://help.syncfusion.com/xamarin/introduction/control-dependencies  

Note: Clean and Rebuild the projects after remove the assemblies.

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

Regards,
Parthiban S
 


Gianluca Esposito
Replied On October 3, 2017 04:55 AM UTC

Everything works fine!

Thank you very much


Parthiban Sundaram [Syncfusion]
Replied On October 4, 2017 06:37 AM UTC

Hi Gianluca,

Thanks for the update. We are glad that the given solution has helped to resolved the issue. Please let us know, if you need further assistance on this.

Regards,
Parthiban S

elbrinner
Replied On October 14, 2018 05:03 PM UTC

Hello,

I'm having the same problem with the android version and I do not see the problem. Can you help me? My code is this:

https://github.com/elbrinner/curso-introduccion-xamarin-forms-2018-XamarinMadrid/tree/master/XamarinMadrid2018/Fin

Selecting an item from the list fails in android when painting the graphic.

Thank you

Michael Prabhu M [Syncfusion]
Replied On October 15, 2018 11:36 AM UTC

Hi Elbrinner,   
   
Greetings from Syncfusion, we have analyzed your sample and the reported issue occurs since you have added "Syncfusion.Xamarin.SfChart.Android" assembly in the Xamarin.Forms.Android project which is not necessary. "Syncfusion.Xamarin.SfChart.Android" is for Xamarin.Android and not for Forms. 
Similarly, for iOS as well. 
   
Please refer the below screenshot for better understanding of the assemblies required in Xamarin.Forms.Android   
   
Screenshot:   
     
   
Also, we have prepared a simple sample for your reference and it can be downloaded from the link below.   
   
   
Thanks,   
Michael   



elbrinner
Replied On October 15, 2018 06:10 PM UTC

It works for me Remove the library and clean.

On Saturday I will use 2 syncfusion components in a mini introductory course to Xamarin Forms.

Thank you

Michael Prabhu M [Syncfusion]
Replied On October 16, 2018 07:12 AM UTC

Hi Elbrinner,  
  
Glad! we could help. Feel free to contact us anytime if you need any other assistance from us. We are happy to help you.   
  
Thanks,  
Michael  
 


CONFIRMATION

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.

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

;