Problems uploading file in MongoDB

I am trying to upload a file to a remote MongoDB from a local C # Console application using the official C # driver. The code I'm running is very straight forward so I don't understand the meaning of the Exception that appears every time I run it and what to do with it.

new MongoClient(ConnectionString)
    .GetServer()
    .GetDatabase("db")
    .GridFS
    .Upload(fileStream, "fileName.ext");

      

Always throws an exception:

An unhandled exception of type "Fixing System.InvalidOperationException" occurred in MongoDB.Driver.dll

Additional info: The stream is at RequestStart and the current server instance does not match the read preference provided.

+3


source to share





All Articles