With var netNamedPipeLocation = "net.pipe://localhost/myservice/";
netNamedPipeLocation + "/mex"
winds up being net.pipe://localhost/myservice//mex
. Your AddServiceEndPoint
call should be
svh.AddServiceEndpoint(
ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexNamedPipeBinding(),
netNamedPipeLocation + "mex"
);
After removing the extra / I was able to connect to a local named pipe service hosted using your code without issue.