【发布时间】:2014-07-24 15:03:53
【问题描述】:
我已经像这样创建了一个 net.tcp WCF 服务:
const string tcpUri = "net.tcp://localhost:9038";
var netTcpHost = new WebServiceHost(typeof(DashboardService), new Uri(tcpUri));
netTcpHost.AddServiceEndpoint(typeof(IDashboardService), new NetTcpBinding(),
"/dashboard");
netTcpHost.Open();
Console.WriteLine("Hosted at {0}. Hit any key to shut down", tcpUri);
Console.ReadKey();
netTcpHost.Close();
这是我的IDashboardService 和DashboardSerivce 定义:
[ServiceContract]
public interface IDashboardService
{
[OperationContract]
PositionDashboard Loader();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class DashboardService : IDashboardService
{
public PositionDashboard Loader()
{
...
}
}
但是,当我尝试使用 WCF 测试客户端连接到服务时,我收到以下错误:
Error: Cannot obtain Metadata from net.tcp://localhost:9038/dashboard
The socket connection was aborted. This could be caused by an error processing your
message or a receive timeout being exceeded by the remote host, or an underlying
network resource issue. Local socket timeout was '00:04:59.9890000'. An existing
connection was forcibly closed by the remote host
【问题讨论】:
标签: c# wcf tcp metadata nettcpbinding