C# 基础连接已关闭:接收时发生意外错误
下面是一个后续问题:关于我收到的答案。我不确定发生了什么,但我得到一个错误:C# 基础连接已关闭:接收时发生意外错误,c#,linq,web-services,rest,entity-relationship,C#,Linq,Web Services,Rest,Entity Relationship,下面是一个后续问题:关于我收到的答案。我不确定发生了什么,但我得到一个错误: 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, RoutedE
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;
}
由于您返回的是对象的
列表
,因此您可能已经超出了默认值。您可以通过修改web.config(或app.config)来增加该值:
你也可以考虑看通常的嫌疑犯:
值- MaxReceivedMessageSize
- MaxBufferSize
- MaxBufferPoolSize
您应该启用,因为它将包含更详细的错误。是的,这甚至适用于自托管应用程序。?不这样做,你会看到详细的错误:)这是托管在一个控制台应用程序中,所以不要认为这会起作用。如果你通过浏览器点击uriGroup的URL,你会看到什么?@JungleBoogie,Reniuz是对的。即使您是自托管,也可以启用WCF跟踪。修改你的app.config而不是web.config没有app.config或web.config。@Downvoter,我非常感谢对我的回答提出建设性的批评,以便我将来能提供更好的回答。请分享你的想法和意见。
<behaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</behaviors>