I am trying to open an interface through NetNamedPipeBinding.
That's what I'm doing:
try { //load the shedluer static constructor ServiceHost svh = new ServiceHost(typeof(MyClass)); var netNamedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); var netNamedPipeLocation = "net.pipe://localhost/myservice/"; svh.AddServiceEndpoint(typeof(IMyInterface), netNamedPipeBinding, netNamedPipeLocation); // Check to see if the service host already has a ServiceMetadataBehavior ServiceMetadataBehavior smb = svh.Description.Behaviors.Find<ServiceMetadataBehavior>(); // If not, add one if (smb == null) smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; svh.Description.Behaviors.Add(smb); // Add MEX endpoint svh.AddServiceEndpoint( ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexNamedPipeBinding(), netNamedPipeLocation + "/mex" ); svh.Open(); Console.WriteLine("Service mounted at {0}", netNamedPipeLocation); Console.WriteLine("Press ctrl+c to exit"); ManualResetEvent me=new ManualResetEvent(false); me.WaitOne(); svh.Close(); } catch (Exception e) { Console.WriteLine("Exception"); Console.WriteLine(e); }
The service starts fine, but when I create a new Visual Studio project and try to add a link to the service in location net.pipe://localhost/myservice/ , I get the following error:
The URI prefix is not recognized. Metadata contains a reference that cannot be resolved: 'net.pipe://localhost/myservice/'. Metadata contains a reference that cannot be resolved: 'net.pipe://localhost/myservice/'. If the service is defined in the current solution, try building the solution and adding the service reference again.
If I replace NetNamedPipeBinding for TcpBinding, the code works fine and a link to the service can be added.
What should I change to add service references in Visual Studio?
source share