[CSHARP-1485] NullReferenceException when saving an ExpandoObject property Created: 23/Nov/15 Updated: 16/Nov/21 Resolved: 07/Jun/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 2.13.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Davide Icardi | Assignee: | James Kovacs |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
I have a class like:
When I trying to insert it in MongoDb without setting ExtraData property (so leaving it to null) I get a NullReferenceException exception. |
| Comments |
| Comment by Githook User [ 07/Jun/21 ] |
|
Author: {'name': 'James Kovacs', 'email': 'jkovacs@post.harvard.edu', 'username': 'JamesKovacs'}Message: |
| Comment by James Kovacs [ 03/Jun/21 ] |
|
Hi, Brecht, Thank you for bringing this back to our attention. I have confirmed that it is still an issue in the latest version of the driver and I have implemented a fix, which will be available in an upcoming release. Sincerely, |
| Comment by Brecht Vanhaesebrouck [ 31/May/21 ] |
|
I just had the same problem (with the most recent version of the driver) |
| Comment by Davide Icardi [ 20/Sep/16 ] |
|
Here a very easy example to reproduce the error: public class MyClass } var myClass = new MyClass {MyProperty1 = null}; var myClass = new MyClass {MyProperty1 = new ExpandoObject()}; |
| Comment by Davide Icardi [ 10/Feb/16 ] |
|
Sorry for the late response .... var metaObject = value.GetMetaObject(Expression.Constant(value)); A similar problem is during deserialize on the DynamicDocumentBaseSerializer.Deserialize because It doesn't handle BsonType.Null. There is a reason for this? I have tried creating a NullableExpandoObjectSerializer and checking for null on both Serialize and Deserialize and seems to work as expected. thanks |
| Comment by Craig Wilson [ 23/Nov/15 ] |
|
Thanks for the report Davide. Could you provide a stack trace? Craig |