我使用NetTcpBinding和Streamed TransferMode。现在我试图实现一个回调作为双工,但我得到了错误信息。可以将NetTcpBinding与Streamed TransferMode结合使用并使用(双工)回调服务契约? 背景: - 我使用NetTcpBinding,因为它速度很快并且没有nat问题 - 我使用流式传输模式,因为我也传输大文件。WCF,NetTcpBinding,流传输模式可以是双工的?
的配置:
<netTcpBinding>
<binding name="DuplexBinding" transferMode="Streamed"
closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600"
>
<readerQuotas maxDepth="104857600" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/>
<reliableSession enabled="true" ordered="true" inactivityTimeout="00:10:00"/>
<security mode="None" />
</binding>
</netTcpBinding>
合同:
IMyDataService.cs
[ServiceContract(CallbackContract = typeof(INotifyCallback))]
public interface IMyDataService
{
[OperationContract(ProtectionLevel = System.Net.Security.ProtectionLevel.None)]
[FaultContract(typeof(MyFaultException))]
[FaultContract(typeof(MyUserAlreadyLoggedInFaultException))]
[FaultContract(typeof(AuthorizationFaultException))]
Guid Authenticate(Guid clientID, string userName, string password, bool forceLogin);
}
INotifyCallback.cs
public interface INotifyCallback
{
[OperationContract(IsOneWay = true)]
void ShowMessageBox(string message);
}
我有得到错误了when设置transferMode = “流”
合同要求双面打印,但绑定 'NetTcpBinding的'不支持 它或未正确配置以支持它。
每个人都可以建议感谢
您是否使用DuplexChannelFactory连接到服务器(或者只是一个ChannelFactory)? – EthanB
我使用IMetadataExchange添加servicereferece并创建客户端代理 –