基础连接已关闭:接收时发生意外错误
本文关键字:错误 意外 连接 | 更新日期: 2023-09-27 18:32:29
这是这里的后续问题:与我收到的答案建立关系的linq问题。我不确定发生了什么,但我收到一个错误:
The underlying connection was closed: An unexpected error occurred on a receive.
这就是异常发生的地方:
string uriGroup = "http://localhost:8000/Service/Group";
private void ListGroups_Click(object sender, RoutedEventArgs e)
{
XDocument xDoc = XDocument.Load(uriGroup); // this line
var groups = xDoc.Descendants("Group")
.Select(n => new
{
GroupName = n.Element("GroupName").Value,
GroupHeader = n.Element("GroupHeader").Value,
TimeCreated = DateTime.Parse(n.Element("TimeAdded").Value),
Tags = n.Element("Tags").Value,
Messages = n.Element("GroupMessages").Value
})
.ToList();
dataGrid2.ItemsSource = groups;
}
由于您返回的对象List
,因此您可能已经超过了MaxItemsInObjectGraph。 您可以通过修改 web.config(或 app.config)来增加该值:
<behaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</behaviors>
您可能还需要考虑查看通常的嫌疑人:
-
<readerquota>
值 - 最大接收消息大小
- 最大缓冲区大小
- 最大缓冲池大小
应启用 WCF 跟踪,因为它将包含更详细的错误。是的,这甚至适用于自托管应用。