Error: System.NullReferenceException: Object reference not set to an instance of an object.

I updated from v18.3.53 to v18.4.46, and now received this error for my 'SfAccumulationChart' component.





Also, I would like to use 'HtmlAttribute' for 'SfAccumulationChart' to apply css styling. How can I do this?

3 Replies 1 reply marked as answer

SM Srihari Muthukaruppan Syncfusion Team March 4, 2021 07:15 AM UTC

Hi Kenney, 
 
We have analyzed your query. From that, the reported scenario occurs due to the get set value is not set for the datasource class provided in the code snippet. We have modified the sample based on your requirement. Please find the sample, code snippet, and screenshot below for your reference. 
 
Regarding applying CSS style for accumulation chart we suggest you to use CustomClass property available in the accumulation chart to achieve your requirement.  
 
 
Code Snippet: 
// add your additional code here 
 
public class Statistics 
    { 
        public string PersonType { get; set; } 
        public double Count { get; set; } 
    } 
 
// add your additional code here 
 
 
Screenshot: 
 
 
Let us know if you have any concerns. 
 
Regards, 
Srihari M 


Marked as answer

MA markelvy July 5, 2021 04:52 AM UTC

In a nutshell it means.. You are trying to access an object without instantiating it.. You might need to use the "new" keyword to instantiate it first i.e create an instance of it from class.


public class MyClass

{

   public int Id {get; set;}

}


MyClass myClass;


myClass.Id = 0; //error comes here


You will have to use:


myClass = new MyClass();

myClass.Id = 0;





DG Durga Gopalakrishnan Syncfusion Team July 6, 2021 02:28 PM UTC

Hi markelvy, 

Thanks for an update. Please revert us if you need any further assistance. 

Regards, 
Durga G

Loader.
Up arrow icon