SfDataGrid Deserialize Error: NullReferenceException: 'Object reference not set to an instance of an object.'
Seems simple. I can Serialize
on closing the app
to an XML file that looks fine to me. But I am completely unable to Deserialize it,
Same error if the grid is on the main form or in a docking form. Same error if the Deserialize happened on form load or from a toolbar button press.
The SfDataGrid seems fine: it gets loaded with data and works fine. The XML file (Attached) opens fine. What am I missing?
Attachment: DataGrid_d5bdac1c.zip
Hi Keith Sanker,
We have checked the reported issue with the provided details. Unfortunately, we are unable to reproduce the reported issue on our end. Here, we have attached the tested sample and a video demo for your reference. Please have a look at this. Could you please confirm if we missed anything? If you are still facing the reported issue please share the below things,
Modify the attached sample based on your scenario
Provide a video illustration of the reported issue.
It will be helpful for us to check on it and provide you with a solution at the earliest.
Regards,
Dhanasekar M.
Attachment: Sample__VideoDemo_34e379f4.zip
The sample worked fine in my environment, so I commented out the local datasource and updated it to connect to my SQL datasource (Binding Data from ADO .NET Entity Framework.) I teaked wth sfdatagrid slightly to match mine (Reorder columns, resize columns, enable virtual, and column auto create). And I cleared out the previous "DataGrid.xml" from the bin/debug directory.
My video shows compiling the modified source and the sfDataGrid being populated and manipulated a little. I exit the app and restart and the Deserialization error occurs. The DataGrid.xml that got created when I existed the first time is in the in bin/debug directory. I zipped up the entire project and my video and attached it.
Thanks for looking into this.
Attachment: UpdatedSample__VideoDemo_with_Error_9b802c62.zip
Keith Sanker,
We have tried to check the reported issue with your provided sample, and we
regret to let you know that we are unable to run the attached sample and facing
the below error shown in the screenshot,
And here we have attached the call stack for it, please have a look at this. Please share the runnable sample. It will be helpful for us to check on it and provide you with a solution at the earliest.
Attachment: 182583_ExceptionDetails_3a6027e8.zip
I have been unable to recreate the issue without connecting to my test database, So I've attached an SQL express backup of it. If you restore that on you local machine you should be able to get the UpdatedSample provided before to run.
Let me know if you require more.
Attachment: FontTestDB_b349bcb1.zip
Keith Sanker,
During our attempt to reproduce the reported issue, we encountered a null exception. We have attached the stack trace for your reference. Could you please verify if you are experiencing the same exception on your end? Your confirmation will help us proceed with further investigation and provide appropriate assistance.
Attachment: Exception_Stacktrace_9f99de31.docx
Keith Sanker,
After analyzing the reported issue with the provided sample, we have identified that the EnableDataVirtualization property in your application is causing the problem. When you enable the EnableDataVirtualization property and bind a DataTable to the SfDataGrid, it does not support the DataTable collection by default. Enabling or disabling the EnableDataVirtualization property does not have any impact on the DataTable collection.
We recommend you remove the EnableDataVirtualization property to overcome the reported issue. Please let us know if you have any concerns about this.
Disabling the EnableDataVirtualization property does indeed resolve the NullReferenceException, thank you.
It does raise the question of what kind of data sources does the EnableDataVirtualization
property work with. Could you inform on that point? In the sfDataGrid DataVirtualization sample I found, they created a List of objects and bound to that. I was hoping to avoid reading a couple million records to build a local structure before using a virtualized grid. Does it work if I create a DataSet and fill it from the database? What are the options? Thanks.
Keith Sanker,
We regret to let you know that, our SfDataGrid's DataVirtualization feature does not support any type of DataTable collections. This includes scenarios where you create a DataSet and fill it from a database, as it will still be treated as a DataTable. Therefore, it is not possible to use the EnableDataVirtualization property with DataTable collections.
OK. So I reworked the sample to read the database into a List of Info structures, like the sample, and used that as the DataSource for the sfDataGrid. With the
the EnableDataVirtualization property set to false everything is fine. However, when I set the property to true, I get the exact same error on Deserialization as I did when I was using a DataTable. That's doesn't seem right. Is there some other setting that's not correct?
I've attached the updated sample code, a video demo of the error, and the stacktrace.
Attachment: UpdatedSample__VideoDemo_with_Error_701313ca.zip
Keith Sanker,
We have checked the reported issue “NullReferenceException
occurs while performing the Deserialization with EnableDataVirtualization” on
our end and it is confirmed as a defect. And We have logged a bug. We will fix
this issue and include it in our NuGet release Which is scheduled on July 11,
2023. We will share the feedback on tomorrow (June 20, 2023).
We appreciate your patience until then.
Keith Sanker,
As we mentioned in our previous update, we will fix this
issue and include it in our NuGet release Which is scheduled on July 11, 2023.
You can track the status of this report through the following feedback link,
Feedback Link: https://www.syncfusion.com/feedback/44587/nullreferenceexception-occurs-while-performing-the-deserialization-with
Note: The provided feedback link is private, and you need to log in to view this feedback.
We
will let you know once it is released. We appreciate your patience until then.
Keith Sanker,
We would like to let you know that Essential Studio Weekly NuGet packages (v22.1.37)
have been published in nuget.org with the fix for the issue “NullReferenceException
occurs while performing the Deserialization with EnableDataVirtualization”
Please let us know if you have any concerns about this.
Thank You. I can confirm the issue is resolved.
- 14 Replies
- 2 Participants
- Marked answer
-
KS Keith Sanker
- May 26, 2023 10:39 AM UTC
- Jul 6, 2023 08:09 PM UTC