WCF zero application endpoint exception

Posted by Lijo on Stack Overflow See other posts from Stack Overflow or by Lijo
Published on 2010-06-05T13:44:30Z Indexed on 2010/06/05 13:52 UTC
Read the original article Hit count: 298

Filed under:

Hi Team,

I am just trying with various WCF(in .Net 3.0) scenarios.

I am using self hosting.

I am getting an exception as "Service 'MyServiceLibrary.NameDecorator' 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."

I have a config file as follows (which has an endpoint)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.serviceModel>
    <services>

      <service name="Lijo.Samples.NameDecorator"
               behaviorConfiguration="WeatherServiceBehavior">

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8010/ServiceModelSamples/FreeServiceWorld"/>
          </baseAddresses>
        </host>

        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="Lijo.Samples.IElementaryService" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WeatherServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

And a Host as

using System.ServiceModel;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Runtime.Serialization;

namespace MySelfHostConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            System.ServiceModel.ServiceHost myHost = new ServiceHost(typeof(MyServiceLibrary.NameDecorator));
            myHost.Open(); 
            Console.ReadLine();
        }
    }


}

My Service is as follows

using System.ServiceModel;
using System.Runtime.Serialization;

namespace MyServiceLibrary
{
    [ServiceContract(Namespace = "http://Lijo.Samples")]
    public interface IElementaryService
    {
        [OperationContract]
        CompanyLogo GetLogo();
    }

    public class NameDecorator : IElementaryService
    {
        public CompanyLogo GetLogo()
        {

            CircleType cirlce = new CircleType();
            CompanyLogo logo = new CompanyLogo(cirlce);
            return logo;
        }
    }

    [DataContract]
    public abstract class IShape 
    {
        public abstract string SelfExplain();

    }

    [DataContract(Name = "Circle")]
    public class CircleType : IShape 
    {
        public override string SelfExplain()
        {
            return "I am a Circle";
        }
    }

    [DataContract(Name = "Triangle")]
    public class TriangleType : IShape
    {
        public override string SelfExplain()
        {
            return "I am a Triangle";
        }
    }

    [DataContract]
    [KnownType(typeof(CircleType))]
    [KnownType(typeof(TriangleType))]
    public class CompanyLogo
    {
        private IShape m_shapeOfLogo;

        [DataMember]
        public IShape ShapeOfLogo
        {
            get
            {
                return m_shapeOfLogo;
            }
            set
            {
                m_shapeOfLogo = value;
            }
        }

        public CompanyLogo(IShape shape)
        {
            m_shapeOfLogo = shape;
        }
    }

}

Could you please help me to understand what I am missing here?

Thanks

Lijo

© Stack Overflow or respective owner

Related posts about wcfservice