我在 Atlas 上有一个 MongoDB,我正在从 ASP.NET Core MVC 应用程序中查询它。在我的 Context 类中,我从构造函数初始化 MongoClient,如下所示:var client = new MongoClient(settings.Value.ConnectionString);if (client != null){ _database = client.GetDatabase(settings.Value.DatabaseName);}存储库类作为瞬态服务注入到我的控制器中services.AddTransient<IMovieRepository, MovieRepository>();如果我尝试从该数据库的集合中获取某些内容,则第一次尝试时一切正常。如果我刷新页面,它会尝试再次创建 MongoClient 并失败向我抛出DnsResponseException. 之后我必须等待一分钟左右,它才能再次工作。Robo3T 让我可以执行任意数量的连续查询,因此我猜问题可能只出现在 C# MongoClient 上......这是我得到的完整异常:;; Error: Cannot read byte 269, out of range.System.IndexOutOfRangeException: Cannot read byte 269, out of range. at DnsClient.DnsDatagramReader.ReadByte() at DnsClient.DnsDatagramReader.ReadLabels() at DnsClient.DnsDatagramReader.ReadQuestionQueryString() at DnsClient.DnsRecordFactory.ReadRecordInfo() at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData) at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout) at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit);; Error: Cannot read byte 269, out of range.System.IndexOutOfRangeException: Cannot read byte 269, out of range. at DnsClient.DnsDatagramReader.ReadByte() at DnsClient.DnsDatagramReader.ReadLabels() at DnsClient.DnsDatagramReader.ReadQuestionQueryString() at DnsClient.DnsRecordFactory.ReadRecordInfo() at DnsClient.DnsMessageHandler.GetResponseMessage(ArraySegment`1 responseData) at DnsClient.DnsUdpMessageHandler.Query(IPEndPoint server, DnsRequestMessage request, TimeSpan timeout) at DnsClient.LookupClient.ResolveQuery(IReadOnlyCollection`1 servers, DnsMessageHandler handler, DnsRequestMessage request, Boolean useCache, LookupClientAudit continueAudit)有谁知道我为什么会遇到此异常以及如何解决它?
添加回答
举报
0/150
提交
取消