Service has zero application (non-infrastructure) endpoints

后端 未结 16 1665
抹茶落季
抹茶落季 2020-12-02 18:05

I recently created a WCF service (dll) and a service host (exe). I know my WCF service is working correctly since I am able to successfully add the service to WcfTestClient.

相关标签:
16条回答
  • 2020-12-02 18:27

    I just worked through this issue on my service. Here is the error I was receiving:

    Service 'EmailSender.Wcf.EmailService' 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.

    Here are the two steps I used to fix it:

    1. Use the correct fully-qualified class name:

      <service behaviorConfiguration="DefaultBehavior" name="EmailSender.Wcf.EmailService">
      
    2. Enable an endpoint with mexHttpBinding, and most importantly, use the IMetadataExchange contract:

      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      
    0 讨论(0)
  • 2020-12-02 18:28

    The endpoint should also have the namespace:

     <endpoint address="uri" binding="wsHttpBinding" contract="Namespace.Interface" />
    
    0 讨论(0)
  • 2020-12-02 18:31

    Today i ran into same issue, posting here my mistake and correction of it so that it may help someone.

    While Re-structuring code, I had actually changed Service class and IService names and changed ServiceHost to point to this new Service class name (as shown in code snippet) but in my host applications App.Config file i was still using old Service class name.(refer config section's name field in below snippet)

    Here is the code snippet,

     ServiceHost myServiceHost = new ServiceHost(typeof(NewServiceClassName)); 
    

    and in App.config file under section services i was referring to old serviceclass name , changing it to New ServiceClassName fixed issue for me.

      <service name="ProjectName.OldServiceClassName"> 
            <endpoint address="" binding="basicHttpBinding" contract="ProjectName.IService">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <host>
              <baseAddresses>
                <add baseAddress=""/>
              </baseAddresses>
            </host>
          </service>
    
    0 讨论(0)
  • 2020-12-02 18:32

    To prepare the configration for WCF is hard, and sometimes a service type definition go unnoticed.

    I wrote only the namespace in the service tag, so I got the same error.

    <service name="ServiceNameSpace">
    

    Do not forget, the service tag needs a fully-qualified service class name.

    <service name="ServiceNameSpace.ServiceClass">
    

    For the other folks who are like me.

    0 讨论(0)
  • 2020-12-02 18:33

    I had the same problem. Everything works in VS2010 but when I run the same project in VS2008 I get the mentioned exception.

    What I did in my VS2008 project to make it work was adding a call to the AddServiceEndpoint member of my ServiceHost object.

    Here is my code snippet:

    Uri baseAddress = new Uri("http://localhost:8195/v2/SystemCallbackListener");
    
    ServiceHost host = new ServiceHost(typeof(SystemCallbackListenerImpl), baseAddress);
    
    host.AddServiceEndpoint(typeof(CsfServiceReference.SystemCallbackListener),
                            new BasicHttpBinding(),
                            baseAddress);
    host.Open();
    

    I didn't modify the app.config file. But I guess the service endpoint could also have been added in the .config file.

    0 讨论(0)
  • 2020-12-02 18:34

    One crucial thing to remember for those working with a Console application to host the WCF service is that the Web.config file in the WCF project is completely ignored. If your system.serviceModel configuration is there, then you need to move that section of config to the App.config of your Console project.

    This is in addition to the answers concerning ensuring the namespace is specified in the right places.

    0 讨论(0)
提交回复
热议问题