我已经阅读了很多解决问题的可能性
"服务器未提供有意义的回复;这可能是造成的 合同不匹配,过早会话关闭或内部 服务器错误"
WCF例外,
但他们都没有为我工作。 我有一个服务方法,它通过EntityFramework执行linq查询,并且用户可以选择启用或禁用导航属性的加载。这是功能。
public List<DataTransferObjects.Equipment> GetEquipments(bool Include = true)
{
using (Entities.DBEntities context = new Entities.DBEntities())
{
return Include ? (from equipment
in context.Equipments
.Include(equipment => equipment.A)
.Include(equipment => equipment.B)
.Include(equipment => equipment.C)
.Include(equipment => equipment.D)
select equipment)?.ToDataTransferObjects<Entities.Equipment, DataTransferObjects.Equipment>().ToList()
:
(from equipment
in context.Equipments
select equipment)?.ToDataTransferObjects<Entities.Equipment, DataTransferObjects.Equipment>().ToList()
}
}
当我通过生成的服务引用使用false Include值调用该函数时,它可以正常工作,但是当Include为true时,它会抛出异常。我确定问题是消息的大小或一些相关的大小问题,因为如果我更改函数以请求前20条记录它工作正常(整个表包含94条记录),所以工作linq查询
(from equipment
in context.Equipments
.Include(equipment => equipment.A)
.Include(equipment => equipment.B)
.Include(equipment => equipment.C)
.Include(equipment => equipment.D)
select equipment).Take(20)?.ToDataTransferObjects<Entities.Equipment, DataTransferObjects.Equipment>().ToList()
配置如下
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="DefaultBinding" transferMode="Buffered" maxBufferSize="2147483646" maxBufferPoolSize="2147483646" transactionProtocol="OleTransactions" maxReceivedMessageSize="2147483646">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<!--<security mode="Transport"> Nothing changed with this option
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows"/>
</security>-->
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DefaultBehaviour" name="ServiceLibrary.Service">
<endpoint address="WCFService" binding="netTcpBinding" bindingConfiguration="DefaultBinding" contract="ServiceLibrary.IService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
答案 0 :(得分:0)
以下是一些需要考虑的事项
客户端和服务器都负责为大小等设置配置值,如果您担心此类事情,请确保正确设置客户端配置。 / p>
如果你认为它的大小问题,只限于一个或几个记录,这应该给你一个很好的指示。
我的钱已经开启不是大小设置(MaxReceivedMessageSize
错误或类似的东西),更可能是其中一个嵌套合同中的序列化问题。尝试一次实施一个包含
作为奖金提示,这是对三元运营商的完全滥用,看起来很恶心:)只是说......
祝你好运