Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7600647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:57:43+00:00 2026-05-30T22:57:43+00:00

An error occurred while deserializing the Property1 property of class Class1: ReadString can only

  • 0

“An error occurred while deserializing the Property1 property of class Class1: ReadString can only be called when CurrentBsonType is String, not when CurrentBsonType is ObjectId.”

I put the bsonid on the string guid of the class and mapped the class and serialized it, but it is giving me this error when I tried to deserialize my object back to the class from a bsondocument.

How should I fix this?

public class Class1 
{
      [BsonId]
      public string ClassGuid { get; private set; }
}

Then map the class:

if (!BsonClassMap.IsClassMapRegistered(typeof(WordOntology)))
{
      BsonClassMap.RegisterClassMap<WordOntology>();
}

Then deserialize

MongoCursor<Class1> _returnResults = _collection.FindAs<Class1>(_query);

Then loop:

foreach(BsonDocument _document in _returnResults) 
{
    //exception here
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:57:45+00:00Added an answer on May 30, 2026 at 10:57 pm

    You probably have existing documents in your collection that do not match your class definition. You can look for them using the mongo shell (look for documents that have an ObjectId where you are expecting a string to be).

    If that doesn’t explain it, can you provide your class declaration and a sample document (displayed using the mongo shell) that won’t deserialize properly?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this error An error occurred while parsing EntityName. Line 1, position 61.
I'M getting crazied for that ERROR A network-related or instance-specific error occurred while establishing
An error has occurred while establishing a connection to the server. When connecting to
I get an 'An error occurred while processing this request' Exception when I try
I am having this problem An error occurred while trying to make a request
So here is the error... An error occurred while saving the Panel. System.ArgumentOutOfRangeException: Index
Anyone have a clue what this error message means? An unexpected error occurred while
When calling context.SaveChange() , I get an exception: {An error occurred while updating the
The following error occurred while trying to add or remove files in the installation
I get this: An error occurred while receiving the HTTP response to http://localhost:8732/Design_Time_Addresses/PersistencyService/Service1/ .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.