我有一个 WCF 服务,使用NetTcpBinding TransferMode.Streamed,我正在寻找使用它的回调流回客户端,但我得到了这个异常host.Open
:
Contract requires Duplex, but Binding 'NetTcpBinding' doesn't support it or isn't configured properly to support it.
ServiceHost host;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Uri baseAddress = new Uri(string.Format("net.tcp://{0}:1991/service", Dns.GetHostName()));
host = new ServiceHost(typeof(WCF_Server.MainService), baseAddress);
host.Open();
}
服务接口:
[ServiceContract(CallbackContract = typeof(IScreenCallback))]
public interface IScreenShot
{
[OperationContract]
Stream GetStream(int formatIndex);
[OperationContract]
void ShowGallery();
[OperationContract]
void CloseGallery();
[OperationContract]
void AddImage(Stream stream);
}
public interface IScreenCallback
{
[OperationContract]
void NextImage();
[OperationContract]
void PrevImage();
[OperationContract]
void AddImageClient(Stream stream);
}
我如何将流传递给客户端回调?