Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a WCF in VB which is to be hosted in a Windows Service. I managed the install program so the service actually installs. But, when I try to start the service, I get the following error:

The service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.

Cheking the Event Viewer gives me the following:

Service cannot be started. System.ArgumentException: ServiceHost only supports class service types.
at System.ServiceModel.Description.ServiceDescription.GetService(Type serviceType)
at System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts).........

Anybody have any ideas what's going on? Thanks!

share|improve this question
1  
Please post some code.. how you are opening the service host? – ukhardy May 11 '11 at 0:05
did this actually work? – A J May 8 at 9:24
Hi AJ - It's been a while, but I checked the first answer below after doing a little research. David Steele was correct. – Jason May 16 at 17:31

2 Answers

up vote 1 down vote accepted

The ServiceHost constructor must be concrete implementation of service contract.

It sounds like you are passing in the Interface rather than the service implementation.

share|improve this answer
I have absolutely no idea what you're talking about. Do you mean the install program??? – Jason May 11 '11 at 15:44
  svh = new ServiceHost(typeof(MCWCFService.MCManagementService));
  svh.AddServiceEndpoint(
          typeof(MCWCFService.IMCManagementService),
          new NetTcpBinding(),
          "net.tcp://192.168.0.2:8011");
  svh.Open();

When creating the ServiceHost use the Class name - in the above it is MCManagementService. In the endpoint, use the interface - in the above it is IMCManagementService.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.