G G*_* Gr 2 c# linq rest entity-relationship web-services
这是一个跟进问题:linq问题与我收到的答案有关.我不确定发生了什么,但我收到一个错误:
The underlying connection was closed: An unexpected error occurred on a receive.
Run Code Online (Sandbox Code Playgroud)
这就是异常发生的地方:
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;
}
Run Code Online (Sandbox Code Playgroud)
Tun*_*ung 10
由于您要返回一个List对象,因此可能已超出MaxItemsInObjectGraph.您可以通过修改web.config(或app.config)来增加值:
<behaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
您可能还想考虑查看通常的嫌疑人:
<readerquota> 值您应该启用WCF跟踪,因为它将包含更详细的错误.是的,这适用于自托管应用程序.