【发布时间】:2015-12-15 16:12:37
【问题描述】:
我正在使用 C# MongoDB.Driver,版本=1.10.1.73。
注意我知道this question,这不是我的问题。
错误信息:
MongoDB.Driver.MongoWriteConcernException:命令“createIndexes” 失败:异常:索引名称:filename_1_uploadDate_1 已经 存在不同的选项(响应:{ “createdCollectionAutomatically”:假,“numIndexesBefore”:4, “errmsg”:“异常:索引名称:filename_1_uploadDate_1 已经存在不同的选项", "code" : 85, "ok" : 0.0 })
MongoDatabase _database;
var query = MongoDB.Driver.Builders.Query.And(
MongoDB.Driver.Builders.Query.EQ(ColumnFilename, filePath),
MongoDB.Driver.Builders.Query.EQ(ColumnWidth, width),
MongoDB.Driver.Builders.Query.EQ(ColumnHeight, height));
var mongoFileInfo = _database.GridFS.FindOne(query);
if (mongoFileInfo != null) {
var mongoStream = mongoFileInfo.OpenRead();
if (/*some condition*/) {
mongoStream.Close();
mongoStream.Dispose();
mongoFileInfo.Delete(); // exception here
}
完整的堆栈跟踪:
MongoDB.Driver.MongoCollection.CreateIndex(IMongoIndexKeys 键, IMongoIndexOptions 选项)
MongoDB.Driver.MongoCollection.CreateIndex(IMongoIndexKeys 键)
MongoDB.Driver.MongoCollection.CreateIndex(String[] keyNames)
MongoDB.Driver.GridFS.MongoGridFS.EnsureIndexes(Int32 maxFiles)
MongoDB.Driver.GridFS.MongoGridFS.EnsureIndexes()
MongoDB.Driver.GridFS.MongoGridFSFileInfo.Delete()
【问题讨论】:
-
我看不出这个错误与这段代码有什么关系。哪一行实际上引发了异常?
-
问题中同时标记了堆栈跟踪和抛出异常...
标签: c# mongodb mongodb-query mongodb-.net-driver