Reputation: 745
I am trying to start and stop a WCF service library through a windows desktop application but got stuck. I cannot start it because it gives me error in the shost.Open();
Code:
private void startwcfedcHost()
{
ServiceHost shost = new ServiceHost(typeof(WcfServiceLibrary.Service));
shost.Open();
}
Error:
Service 'WcfServiceLibrary.Service' 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.
But when I try to run my wcf service it works, How can I fix this issue?
Upvotes: 0
Views: 180
Reputation: 87258
Since you don't specify the endpoints via code, you need to specify them via configuration. What you probably have is a missing configuration file. Change the Main
method (if a console application; something like the Page_Loaded
event if you're writing a windows app) to print the following value:
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
That will show the name that the application expects its configuration file to be. Once you have that, make sure that that file exists, and it has the appropriate <system.serviceModel>
section to define the service endpoints.
Upvotes: 2
Reputation: 5172
WCF is about A(address) B(binding) C(contract), you need to specify binding.
Upvotes: 1