Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-496

Casting BsonObjectId to string through System.Convert.ToString fails

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.5
    • Affects Version/s: 1.4.2
    • Component/s: None
    • Labels:
    • Environment:
      Windows

      Using System.Convert.ToString to handle casts of BsonObjectId to string does not work.

      When used together with a class that uses BsonObjectId this creates an InvalidCastExpection even though the class supports direct Object.ToString() conversion.

      The problem is that MongoDB.Bson.BsonValue.System.IConvertible.ToString(IFormatProvider provider) does NOT support casting of BsonObjectId.

      I have specificly encountered the issue when using ASP MVC's ListBox HtmlHelper together with an object using BsonObjectId as id.

      I have attached an example error message.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            torm Hans Torm
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: