System.NotSupportedException: 'BSON type not supported'
See original GitHub issueHi everybody, I’ve just faced an issue with my LiteDb. After some period of work I found this error in my stackTrace (BSON type not supported). I attached link where you can get db file. It’s crashing while I am trying to open ‘matches’ table.
System.NotSupportedException: ‘BSON type not supported’.
at LiteDB.BsonReader.ReadElement(ByteReader reader, String& name)
at LiteDB.BsonReader.ReadDocument(ByteReader reader)
at LiteDB.QueryCursor.Fetch(TransactionService trans, DataService data, BsonReader bsonReader)
at LiteDB.LiteEngine.Find(String collection, Query query, Int32 skip, Int32 limit)+MoveNext()
at LiteDB.LiteEngine.Find(String collection, Query query, String[] includes, Int32 skip, Int32 limit)+MoveNext()
at LiteDB.LiteCollection1.Find(Query query, Int32 skip, Int32 limit)+MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at RoboWin.BLL.Components.MatchComponent.Services.MatchService.GetAll() in C:\Users\Dim_mon\Desktop\RoboWin\server\RoboWin\RoboWin.BLL\Components\MatchComponent\Services\MatchService.cs:line 30
at RoboWin.Server.Controllers.MatchesController.GetAll() in C:\Users\Dim_mon\Desktop\RoboWin\server\RoboWin\RoboWin.Server\Controllers\MatchesController.cs:line 35
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
My db dump https://drive.google.com/open?id=1X3K7AnM-Nzx2NH-cXykTeBRI63bCqgYk
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top GitHub Comments
I have the same problem, There is still no solution for this problem?
Hi, I have a similar issue, but think I found the problem.
Looks like when serializing dictionaries, if the key string contains null bytes (returned by
ToString()
call on the key object), it gets serialized as-is, see BsonMapper.Serialize.cs#L141.Then, during reading BSON elements, exceptions occur because those null bytes, see BsonReader.cs#L147. The BSON reader reads the null byte int the
type
variable, and null is not a valid type value. The previously read element becomes the key string up to the first null byte.To solve this, I changed the above mentioned dictionary serialization line to the following:
Hope this helps someone.