The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be UuidLegacy, not UuidStandard

Hello friends!

I got an error when I queryed all the collections names in a mongodb database? Can you answer for me the API return error

“{” error “:” The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be UuidLegacy, not UuidStandard. “}”

public IEnumerable <string> Get_AllCollections_in_DB ()
         {
             var client = new MongoClient ("mongodb: // localhost: 27017");
             MongoServer server = client.GetServer ();
             MongoDatabase database = server.GetDatabase ("Uni_Training");
             return database.GetCollectionNames ();
         }

Hello @chu_tinh,

You are using “Legacy” API of the driver which is present only for backward compatibility purposes.

Consider using the regular API:

var client = new MongoClient("mongodb://localhost:27017"); // mind the spaces in the connection string
var database = client.GetDatabase("Uni_Training");
var collectionNames = database.ListCollectionNames().ToList(); // mind the .ToList() call

Thank you for guidelines! (@Mikalai_74493)

Chu Xuân Tình (Viet Nam)