I try to create hard coded wcf service (no app.config) I tried the following
service = new CommService.TwService();
localHost = new ServiceHost(service);
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
localHost.Description.Behaviors.Add(behavior);
localHost.AddServiceEndpoint(typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexNamedPipeBinding(),
"net.pipe://localhost/service/mex/");
localHost.Open();
fails with :
Service ‘CommService.TwService’ has zero application
(non-infrastructure) endpoints. This might be because no
configuration file was found for your application, or because no
service element matching the service name could be found in the
configuration file, or because no endpoints were defined in the
service element.
You have only added an endpoint for Mex, which will not expose the service itself. You need to add another binding explicitly for the service implementation, for example;