开发者

WCF hosted in windows service errors

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.Ge开发者_JAVA百科tService(Type serviceType)

at System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts).........

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


The ServiceHost constructor must be concrete implementation of service contract.

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


  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜