This project has moved and is read-only. For the latest updates, please go here.


JArray.Load fails when loading previously serialized arrays when using BSON.


So this ended up being an issue only when using the BSON reader / writer.

Here are all my settings and codes.

This same scenario works fine with the JsonText reader / writer.
MockClassC[] testItems = TestResourceFactory.GetMockClassCObjects(25).ToArray();

JsonSerializerSettings defaultSettings = new JsonSerializerSettings()
            NullValueHandling = NullValueHandling.Ignore,
            DateTimeZoneHandling = DateTimeZoneHandling.Utc,
            DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
            DateFormatHandling = DateFormatHandling.IsoDateFormat,
            MissingMemberHandling = MissingMemberHandling.Ignore,
            ContractResolver = new DefaultContractResolver() { IgnoreSerializableInterface = true },
            Formatting = Formatting.None,
            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
            TypeNameHandling = TypeNameHandling.Objects, //tried adding arrays with no luck.
            TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple

var ms = new MemoryStream();
var bw = new BsonWriter(ms);

JsonSerializer.Create(defaultSettings).Serialize(bw, testItems);


ms.Position = 0;
var reader = new BsonReader(ms);

JArray.Load(reader); //error here.

Closed Feb 24, 2013 at 4:32 AM by JamesNK
Look at the properties on BsonReader