WCF连接无缘无故出现故障
或者也许它有一个原因,它只是没有告诉我 这就是我为连接我的客户所做的:WCF连接无缘无故出现故障,wcf,Wcf,或者也许它有一个原因,它只是没有告诉我 这就是我为连接我的客户所做的: try { callback = new Callback(); //my callback implementation callback.send += new Callback.gotPacket(callback_send); //Event so the clien
try
{
callback = new Callback();
//my callback implementation
callback.send += new Callback.gotPacket(callback_send);
//Event so the client gets informed when the callback function is
//triggerd.
InstanceContext context = new InstanceContext(callback);
client = new ServiceReference1.WcfInfoHostClient(context);
client.connect();
//This is always working as long as the server is running.
statuslabel.Content = "Conected";
//writing somthing to the GUI
filterentries = client.getFilter();
//this should return a datatable object but it
//always fails due to a ConnectionFaultedException
filtergrid.ItemsSource = filterentries.DefaultView;
//[...]
}
catch (Exception ex)
{
statuslabel.Content = ex.Message;
}
连接怎么会突然出现故障?我将getFilter函数添加到服务接口和服务实现中。我在托管WCF服务的窗口服务中刷新了WCF服务DLL,并刷新了所有相关项目中的所有ServiceReferences。
我看不出这是怎么回事……谢谢你的评论。问题是 WCF不能使用空数据表 b你必须给数据表起一个名字 我将我的实现更改为:
public DataTable getFilter()
{
DataTable result = new DataTable("fascinatingName");
result.Columns.Add(new DataColumn("I", typeof(String)));
result.Columns.Add(new DataColumn("am", typeof(String)));
result.Columns.Add(new DataColumn("a", typeof(String)));
result.Columns.Add(new DataColumn("Test", typeof(String)));
return result;
}
现在通信工作没有问题。WCF仍然让我哭泣
祝大家周末愉快….可能是连接超时了?您是否启用了ServiceModel日志记录以查看发生了什么?连接将在大约100毫秒后超时?此外,当我删除client.getFilter行时,服务会毫无问题地通知回调,所以这不是我的猜测。ServiceModel日志记录需要几个步骤,到目前为止我还无法理解这些步骤,并且需要手动更改高度脆弱的app.conf xml文件,因此直到现在我还没有勇气这么做?它是否使用任何不可序列化的对象?我认为避免超时的简单方法是增加超时并实现某种长池。100ms看起来像是HTTP.SYS基础通道的超时。@Dhawalk:getFilter会:“返回新数据表”