[CSHARP-665] MaxDocuments is Int64 Created: 20/Jan/13  Updated: 20/Mar/14  Resolved: 17/Feb/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.7
Fix Version/s: 1.8

Type: Bug Priority: Major - P3
Reporter: ??? Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

C#Dirver 1.71


Attachments: JPEG File Catch.jpg    
Issue Links:
Duplicate
duplicates CSHARP-639 CollectionStatsResult.MaxDocuments th... Closed

 Description   

When the MaxDocument of Collection is huge,over Int32,there will be a Error
/// <summary>
/// Gets the index count.
/// </summary>
public long MaxDocuments
{
get

{ return Response.GetValue("max", 0).ToInt32(); }

}



 Comments   
Comment by Robert Stam [ 17/Feb/13 ]

Fixed in version 1.8 (see CSHARP-639).

Comment by Craig Wilson [ 17/Feb/13 ]

Yes, you will still get the issue in version 1.7. 1.8 is the fix version for this. It should come out in 2-3 weeks. Robert was simply pointing you at the commit that fixes this issue.

Comment by ??? [ 17/Feb/13 ]

Reply of my client is that:
the MongoDB Driver is 1.7
and the stack trace like this:

System.InvalidCastException: 无法将类型为“MongoDB.Bson.BsonDouble”的对象强制转换为类型“MongoDB.Bson.BsonInt32”。
在 MongoDB.Driver.CollectionStatsResult.get_MaxDocuments()
在 MagicMongoDBTool.Module.MongoDBHelper.FillCollectionStatusToList(ListView lstData) 位置 F:\Downloads\MagicMongoDBTool-master\MagicMongoDBTool-master\MagicMongoDBTool\Module\MongoDBHelper\MongoDBHelper_Status.cs:行号 186

I think there is maybe something wrong with get_MaxDocuments.....

Comment by Robert Stam [ 07/Feb/13 ]

Thank you. Happy Chinese New Year!

Comment by ??? [ 07/Feb/13 ]

Thank you for your reply.
I will confirm the version of C# driver.
As it is Chinese New Year Now,it will take some time to comfirm it.

Comment by Robert Stam [ 07/Feb/13 ]

This is the commit that fixed this issue for 1.7:

https://github.com/rstam/mongo-csharp-driver/commit/4f1050fe7b0a97bfa4aeee4f0a90a0f2afea5306

Comment by Robert Stam [ 07/Feb/13 ]

Can you make sure that you are actually using version 1.7 of the C# driver?

The stack trace you provided shows the driver calling AsInt32, but the current version of the driver calls ToInt32 (which could still theoretically overflow, but would not result in the exception shown by your stack trace).

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