[CSHARP-496] Casting BsonObjectId to string through System.Convert.ToString fails Created: 15/Jun/12  Updated: 02/Apr/15  Resolved: 19/Jun/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.4.2
Fix Version/s: 1.5

Type: Bug Priority: Minor - P4
Reporter: Hans Torm Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Attachments: HTML File cast_is_not_valid.htm    

 Description   

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.


Generated at Wed Feb 07 21:37:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.