C# WCF:客户端调用方法,但不返回

C# WCF:客户端调用方法,但不返回,c#,.net,wcf,C#,.net,Wcf,服务器-客户机体系结构。没有涉及非法入境者。两个应用程序都是WinForm 我在共享库中创建了以下接口: [ServiceContract(SessionMode=SessionMode.Required, CallbackContract=typeof(ClientInterface))] public interface RequestInterface { [OperationContract] void Subscribe(

服务器-客户机体系结构。没有涉及非法入境者。两个应用程序都是WinForm

我在共享库中创建了以下接口:

[ServiceContract(SessionMode=SessionMode.Required,
        CallbackContract=typeof(ClientInterface))]
    public interface RequestInterface
    {
        [OperationContract]
        void Subscribe();

        [OperationContract]
        MyInterface GetInterface();
    }

    public interface MyInterface
    {
        [DataMember]
        List<MySubInterface> SubClasses{get;}
    }

    public interface MySubInterface
    {
        [DataMember]
        int Value { get; }
    }
服务器端的WCF初始化:

using (ServiceHost host = new ServiceHost(
            typeof(RequestHandler),
            new Uri[] { new Uri("net.pipe://localhost") }))
                    {

                        ServiceDebugBehavior tBehavior = new ServiceDebugBehavior();
                        if (null == tBehavior)
                        {
                            host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
                        }
                        else if (!tBehavior.IncludeExceptionDetailInFaults)
                        {
                            tBehavior.IncludeExceptionDetailInFaults = true;
                        }
                        host.AddServiceEndpoint(typeof(RequestInterface),
                          new NetNamedPipeBinding(), "Request");

                        host.Open();
                        Application.Run(new Form1());

                        host.Close();
        }

您能否在
ServiceDebugBehavior
中启用
IncludeExceptionDetailInFaults
,并向我们传达其他信息


检查您的TransmissionClass是否可使用正确的属性(DataContract/DataMember/KnownType)序列化。

放置[KnownTypes]属性,让WCF知道哪些具体类实现了您的接口。

ah OK!。谢谢我一回到我的电脑就可以了。我已经按预期做了。然而,我没有得到任何额外的信息。行为还是一样。我已经更新了我的帖子,提供了关于
TransmissionClass
和服务器端WCF初始化的更多信息。这里还有一个问题:现在只要我只有几个(100)对象,它就可以正常工作,但是当增加(1000000)个数@yas4891时,它会再次失败-当你有1000000个对象时,有什么例外?没有例外。客户机只是从方法返回,没有传递结果。它可以完美地处理小于10000的对象。你是什么意思?客户机是否因此而变为空?您确定服务器返回了结果吗?尝试将nettcpbinding属性的配置(如-MaxReceivedMessageSize、MaxItemsInObjectGraph、MaxDepth、MaxArrayLength)设置为更高的数字…啊。。。我解决了这个问题。WCF正在引发一个CommunicationException,但此异常不会显示在调试器中。谢谢
        ClientClass tClass = new ClientClass(this);
        DuplexChannelFactory<RequestInterface> pipeFactory =
         new DuplexChannelFactory<RequestInterface>(
            tClass,
            new NetNamedPipeBinding(),
            new EndpointAddress(
               "net.pipe://localhost/Request"));

        RequestInterface pipeProxy = pipeFactory.CreateChannel();

        //pipeProxy.Subscribe(); -- works like a charm
        MyInterface tInterface = pipeProxy.GetInterface(); // doesn't work
        fillListView(tInterface);
[DataContract]
[Serializable]
public class TransmissionClass : MyInterface
{
    [DataMember]
    public List<MySubInterface> SubClasses{get;private set;}

    public TransmissionClass(List<MySubInterface> aList)
    {
        SubClasses = aList;
    }

    public override string ToString()
    {
        return "TransmissionClass,Count:" + SubClasses.Count;
    }
}
using (ServiceHost host = new ServiceHost(
            typeof(RequestHandler),
            new Uri[] { new Uri("net.pipe://localhost") }))
                    {

                        ServiceDebugBehavior tBehavior = new ServiceDebugBehavior();
                        if (null == tBehavior)
                        {
                            host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
                        }
                        else if (!tBehavior.IncludeExceptionDetailInFaults)
                        {
                            tBehavior.IncludeExceptionDetailInFaults = true;
                        }
                        host.AddServiceEndpoint(typeof(RequestInterface),
                          new NetNamedPipeBinding(), "Request");

                        host.Open();
                        Application.Run(new Form1());

                        host.Close();
        }