我将 NetTcpBinding 与 Streamed TransferMode 一起使用。现在我尝试将回调实现为双工,但收到错误消息。可以将 NetTcpBinding 与 Streamed TransferMode 一起使用并使用(双工)回调服务合同吗?背景: - 我使用 NetTcpBinding 因为它速度快而且没有 nat 问题 - 我使用流模式,因为我也传输大文件。
配置:
<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);
}
设置 transferMode="Streamed" 时出现错误
合同需要双工,但绑定“NetTcpBinding”不支持它或未正确配置以支持它。
每个人都可以建议谢谢