0

您好,我的 wcf 服务有问题。我正在尝试调用返回类型对象列表的方法。我也在使用实体框架。

public IList<Product> GetAllProducts()
    {
        using (var db = new AuctionContext())
        {
            return db.Products.ToList();
        }
    }

    </service>
  <service name="AuctionSystem.WcfService.ProductService">
    <endpoint address="" binding="wsDualHttpBinding" contract="AuctionSystem.WcfService.Contracts.IProductService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:9993/Design_Time_Addresses/AuctionSystem.WcfService/ProductService/" />
      </baseAddresses>
    </host>
  </service>

和合同:

 [OperationContract]
    IList<Product> GetAllProducts();

该方法本身正在工作,但是当我尝试在我的 wcf 服务 UI 上调用此方法时,它卡在“调用服务”上,我正在使用 wsdualhttpbinding。

请问有什么想法吗?

编辑:我在 Product 对象中意识到我有虚拟列表,为什么这个列表会导致 wcf 挂起?

4

1 回答 1

0

所有人都想知道为什么它是由于循环依赖引起的。

于 2017-12-04T15:11:57.787 回答