WCF连接无故错误

时间:2014-04-10 14:15:38

标签: wcf

或许它有理由不告诉我。

我正在做的是连接我的客户端:

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函数添加到Service接口和Service实现。我在托管它的窗口服务中刷新了WCF服务DLL,并刷新了所有相关项目中的所有ServiceReferences。 我不知道这里有什么东西......

1 个答案:

答案 0 :(得分:0)

感谢您的评论。问题是 a)WCF无法使用空DataTable b)您必须为DataTable命名。

我将实施改为:

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仍让我哭泣。

每个人都度过一个美好的周末....

相关问题