Host WCF in Windows Forms: Error when opening the host

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();


private void startwcfedcHost()
    ServiceHost shost = new ServiceHost(typeof(WcfServiceLibrary.Service));


Service 'WcfServiceLibrary.Service' has zero application (non-infrastructure) 

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?


I suggest you take a look at the following:


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:


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.

WCF is about A(address) B(binding) C(contract), you need to specify binding.

Need Your Help

Problem with HTML Parser in IE

javascript html-parsing

I am trying to create a dialog box that will appear only if the browser selected is IE (any version) however I get this error:

Tesseract-OCR 3.02 with libc++

ios opencv tesseract libc++

Xcode 4.6, iOS SDK 6.1, tesseract-ocr 3.02

Using the jQuery validatation plugin to send multiple values to an ASP.NET MVC controller action? jquery-plugins jquery jquery-validate

Using the jQuery Validation plugin and AJAX, how can I validate the contents of say an input (textbox) but pass more than one parameter to a controller action?