-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 0.9
-
Component/s: None
-
None
If I do this:
using System;
using MongoDB.Bson;
namespace BsonTest
{
internal sealed class Program
{
private static void Main(string[] args)
{
Payload payload = new ChildOfPayLoad
;
payload.ToJson();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
public abstract class Payload
{
private static readonly string _myId = "something";
public string myId
{
get
set { }
}
public abstract string someType
}
public class ChildOfPayLoad : Payload
{
public string name { get; set; }
public string email
{ get; set; } public override string someType
{
get
set { }
}
}
}
I get:
System.ArgumentException: An item with the same key has already been added.
at static void System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at void System.Collections.Generic.Dictionary`2[System.String,MongoDB.Bson.DefaultSerializer.BsonMemberMap].Insert(String key, BsonMemberMap value, Boolean add)
at void System.Collections.Generic.Dictionary`2[System.__Canon,System.__Canon].Add(__Canon key, __Canon value)
at void MongoDB.Bson.DefaultSerializer.BsonClassMap.Freeze() in d:\justin's projects\mongo-csharp\Bson\DefaultSerializer\BsonClassMap.cs:line 303
at static BsonClassMap MongoDB.Bson.DefaultSerializer.BsonClassMap.LookupClassMap(Type classType) in d:\justin's projects\mongo-csharp\Bson\DefaultSerializer\BsonClassMap.cs:line 186
at void MongoDB.Bson.DefaultSerializer.BsonClassMapSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, Boolean serializeIdFirst) in d:\justin's projects\mongo-csharp\Bson\DefaultSerializer\BsonClassMapSerializer.cs:line 160
at static void MongoDB.Bson.Serialization.BsonSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, Boolean serializeIdFirst) in d:\justin's projects\mongo-csharp\Bson\Serialization\BsonSerializer.cs:line 257
at static void MongoDB.Bson.Serialization.BsonSerializer.Serialize(BsonWriter bsonWriter, Object value, Boolean serializeIdFirst) in d:\justin's projects\mongo-csharp\Bson\Serialization\BsonSerializer.cs:line 232
at static String MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Boolean serializeIdFirst, BsonJsonWriterSettings settings) in d:\justin's projects\mongo-csharp\Bson\BsonExtensionMethods.cs:line 110
at static String MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, BsonJsonWriterSettings settings) in d:\justin's projects\mongo-csharp\Bson\BsonExtensionMethods.cs:line 120
at static String MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj) in d:\justin's projects\mongo-csharp\Bson\BsonExtensionMethods.cs:line 93
at static void BsonTest.Program.Main(String[] args) in c:\Users\DearingJ\Documents\SharpDevelop Projects\BsonTest\BsonTest\Program.cs:line 16