[CSHARP-180] Misleading exception message Created: 11/Mar/11 Updated: 02/Apr/15 Resolved: 15/Mar/11 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Eric Z. Beard | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7, latest code from github |
||
| Description |
|
If you get an error like this: MongoDB.Bson.BsonSerializationException: Duplicate element name 'EntryId' in class 'LoopLib.Common.LogEntry' It might not have nothing to do with "EntryId". It's due to a duplicate BsonElement name anywhere in the For example, I had something like this: [BsonId] [BsonElement("a")] public int A { get; set; } [BsonElement("a")] For people who are renaming their fields to save storage space, this will be a common mistake. |
| Comments |
| Comment by Robert Stam [ 15/Mar/11 ] |
|
Improved the error message. For example, the following class: public class C { public ObjectId Id; [BsonElement("a")] public int A; [BsonElement("a")] public int B; }Now results in this error message: Member 'B' of class 'C' cannot use element name 'a' because it is already being used by member 'A'. |
| Comment by Sridhar Nanjundeswaran [ 11/Mar/11 ] |
|
Cannot reproduce the issue of the confusing error message with either the latest C# driver or the C# driver v0.11.0.4042. The error message we got with the with the following code was [BsonElement("a")] public int A { get; set; } [BsonElement("a")] class Program ; |