Getting below error when trying to insert into CosmosDb. Document is being inserted but throwing this error. I'm using .net core 5.0, Microsoft.Azure.Cosmos 3.17.0. Please advise.
Method not found: 'System.Threading.Tasks.Task1<Microsoft.Azure.Cosmos.Serialization.HybridRow.Result> Microsoft.Azure.Cosmos.Serialization.HybridRow.RecordIO.RecordIOStream.ReadRecordIOAsync(System.IO.Stream, System.Func2<System.ReadOnlyMemory1<Byte>,Microsoft.Azure.Cosmos.Serialization.HybridRow.Result>, System.Func2<System.ReadOnlyMemory1<Byte>,Microsoft.Azure.Cosmos.Serialization.HybridRow.Result>, Microsoft.Azure.Cosmos.Serialization.HybridRow.MemorySpanResizer1)'
protected virtual CosmosClient _cosmosClient
{
get
{
var options = new CosmosClientOptions
{
SerializerOptions = new CosmosSerializationOptions
{
IgnoreNullValues = true,
PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
},
AllowBulkExecution = true
};
return new CosmosClient(_connectionString, options);
}
}
protected Container _cosmosContainer
{
get => _cosmosClient.GetContainer(_databaseId, _containerId);
}
protected async Task<T> CreateItemAsync<T>(string id, T model, PartitionKey partitionKey)
{
try
{
return await _cosmosContainer.CreateItemAsync(model, partitionKey);
}
catch (CosmosException ex)
{
LogCosmosDbError(ex);
throw;
}
}
Reference: https://github.com/Azure/azure-cosmos-dotnet-v3/issues/2292#issuecomment-796104041
Repeating what was stated in the comments for future reference: This is often related to DLL mismatching (older DLL for one or more dependencies).
It could be the project contains references to other projects with older versions of the SDK, in which case, make sure all the versions match.
It could also be an issue with your deployment process, maybe when the deployment happens, some DLLs are not getting overwritten, in which case, always make sure you are cleaning the
/binfolder or updating all files with newer versions (some deployment processes might not update DLLs or the DLLs might be locked and currently in use).