求助:WCF ICP问题
我想采用NetNamedPipeBinding实现两个本机进程通信,服务端没报错,但是Add Service报错客户端使用net.pipe://localhost/Service/CalculatorService
Add Service报错:
元数据包含无法解析的引用:“net.pipe://localhost/Service/CalculatorService”。
元数据包含无法解析的引用:“net.pipe://localhost/Service/CalculatorService”。
If the service is defined in the current solution, try building the solution and adding the service reference again.
请问我客户端代码有什么问题吗?
谢谢
服务端部分代码:
class Program
{
static void Main(string[] args)
{
// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
Uri baseAddress = new Uri("net.pipe://localhost/Service");
// Step 1 of the hosting procedure: Create ServiceHost
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
// Step 3 of the hosting procedure: Add a service endpoint.
selfHost.AddServiceEndpoint(
typeof(ICalculator),
new NetNamedPipeBinding(NetNamedPipeSecurityMode.None),
"CalculatorService");
// Step 4 of the hosting procedure: Enable metadata exchange.
//ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
//smb.HttpGetEnabled = true;
//selfHost.Description.Behaviors.Add(smb);
// Step 5 of the hosting procedure: Start (and then stop) the service.
selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("An exception occurred: {0}", ce.Message);
selfHost.Abort();
}
}
}