【发布时间】:2012-08-25 08:16:26
【问题描述】:
我将 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" 时出现错误
Contract 需要 Duplex,但绑定 'NetTcpBinding' 不支持 它或未正确配置以支持它。
每个人都可以建议谢谢
【问题讨论】:
-
您是使用 DuplexChannelFactory 连接到服务器(还是仅使用 ChannelFactory)?
-
我使用 IMetadataExchange 添加 servicereferece 并创建客户端代理