Kru*_*mar 7 c# mongodb asp.net-core mongodb-atlas
我有使用 mongodb 作为后端的 asp.net 核心应用程序。
最近,我开始收到此错误,而数据库或代码没有任何更改。
这是我浏览 API 时遇到的完整错误
An error occurred while starting the application.
InvalidOperationException: Record reader index out of sync.
DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
DnsResponseException: Unhandled exception
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)
InvalidOperationException: Record reader index out of sync.
DnsClient.DnsRecordFactory.GetRecord(ResourceRecordInfo info)
DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment<byte> responseData)
DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout)
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)
Show raw exception details
DnsResponseException: Unhandled exception
DnsClient.LookupClient.ResolveQuery(DnsMessageHandler handler, DnsRequestMessage request, Audit continueAudit)
DnsClient.LookupClient.Query(DnsQuestion question)
MongoDB.Driver.Core.Configuration.ConnectionString.Resolve()
MongoDB.Driver.MongoUrl.Resolve()
MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
MongoDbGenericRepository.MongoDbContext..ctor(string connectionString, string databaseName)
Microsoft.Extensions.DependencyInjection.MongoDbIdentityBuilderExtensions.AddMongoDbStores<TUser, TRole, TKey>(IdentityBuilder builder, string connectionString, string databaseName)
AspNetCore.Identity.MongoDbCore.Extensions.ServiceCollectionExtension.ConfigureMongoDbIdentity<TUser, TRole, TKey>(IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration, IMongoDbContext mongoDbContext)
BrightSteps.Web.Api.Extensions.Utility.ConfigureMongoIdentity(IServiceCollection services, MongoDbSettings settings) in Utility.cs
BrightSteps.Web.Api.Startup.ConfigureServices(IServiceCollection services) in Startup.cs
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Show raw exception details
Run Code Online (Sandbox Code Playgroud)
事实证明,该问题与连接字符串和我的驱动程序版本有关。
C# MongoDB 驱动程序依赖于DNSClient.Net 包,它用于对连接字符串进行 DNS 查找。
由于我使用旧版本的驱动程序,它不支持 mongo db 的 SVR 连接字符串,我必须在 mongodb 中使用非 SVR 连接字符串。
归档时间: |
|
查看次数: |
837 次 |
最近记录: |