【发布时间】:2016-04-22 18:09:51
【问题描述】:
我正在将“旧”代码从 Framework 4.6 迁移到通用应用程序代码以使用 WCF 服务。我有不同的绑定,NetTCPbinding 工作正常,当我在 4.6 框架中配置我的绑定以使用来自 WCF 的 UDPbinding 时我找不到System.ServiceModel 中的 UDPbinding 不再适用于通用应用程序的 .NET。 我需要尽快进行通信,而 .nettcpbinding 似乎还不够。 我添加了作为参考 System.ServiceModel 和 System.ServiceModel.Channels 任何想法? 这是我在 .NETCORE for Universal 中的客户端代码,用于配置与 WCF 服务的连接:
try
{
//Here I cannot find the UDPbinding!!!!!
UdpBinding myBinding = new UdpBinding();
EndpointAddress addr = new EndpointAddress("soap.udp://" + ipAddress + ":" + portNo);
ChannelFactory<IService1> chn = new ChannelFactory<IService1>(myBinding, addr);
IService1 conn = chn.CreateChannel();
return conn;
}
catch (Exception ex)
{
return null;
}
我的服务器服务配置例程是这样的:
private void ConfigService(string portNo) {
host = new ServiceHost(typeof(WCFComm), new Uri("http://localhost:/XXX/XXX"));
// Add service endpoint
UdpBinding myBinding = new UdpBinding();
string address = "soap.udp://localhost:" + portNo;
host.AddServiceEndpoint(typeof(IService1), myBinding, address);
try {host.Open();} catch(Exception ex) {}
}
谢谢,
【问题讨论】:
标签: wcf win-universal-app .net-core