Mech0z Mech0z - 4 years ago 147
C# Question

Cant deserialize inherited object with Mongo c# driver

I am using

nuget package to get some Asp.Net Identity features into my project.

Then I want to extend the
that exists with the User type I originally created for my project, so I tried to inherit from that class and create my User Class that has
as its base class.

If I try to query my collection where I have one
stored and try to deserialize it into
I get that one item out, so success.

But if I try to deserialize it into My User which is just an inherited class of
I get this exception:

Is it not possible to extent a class like that I want? Also the exception is pretty useless, not sure why its not giving me a more detailed exception

The json object looks like this

"_id": "",
"userName": "",
"normalizedUserName": "",
"email": {
"value": "",
"confirmationRecord": null,
"normalizedValue": ""
"phoneNumber": null,
"passwordHash": "xxx",
"securityStamp": "87242bb7-2a09-4905-ba61",
"isTwoFactorEnabled": false,
"claims": [],
"logins": [],
"accessFailedCount": 0,
"isLockoutEnabled": true,
"lockoutEndDate": null,
"createdOn": {
"instant": {
"$date": "2016-11-13T17:05:59.487Z"
"deletedOn": null

Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download