title: Getting error while running Service
body: <p>I have created WCF service but while running the service I am getting below error:
  Error:</p>
  
  <blockquote>
    <p>Failed to add a service. Service
    metadata may not be accessible. Make
    sure your service is running and
    exposing metadata.<br>
    Error Details:<br>
    Warning: No code was generated.If you
    were trying to generate a client, this
    could be because the metadata
    documents did not contain any valid
    contracts or servicesor because all
    contracts/services were discovered to
    exist in /reference assemblies. Verify
    that you passed all the metadata
    documents to the tool.Warning: If you
    would like to generate data contracts
    from schemas make sure to use the
    /dataContractOnly option.</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>namespace WCFTest
  {
      [ServiceContract]
      public class EmployeeDetails
      {
          [OperationContract]
          public List&lt;Employee&gt; GetDetails()
          {
              List&lt;Employee&gt; emp = new List&lt;Employee&gt;()
              {
                 new Employee(){Fname="AA",Lname="BB",EmpId=1,Desg="A"},
                 new Employee(){Fname="CC",Lname="DD",EmpId=1,Desg="B"},
                 new Employee(){Fname="EE",Lname="FF",EmpId=1,Desg="C"},
                 new Employee(){Fname="GG",Lname="HH",EmpId=1,Desg="D"},
                 new Employee(){Fname="II",Lname="JJ",EmpId=1,Desg="A"},
                 new Employee(){Fname="KK",Lname="LL",EmpId=1,Desg="B"}
              };
              return emp;
          }
      }
  
      // Use a data contract as illustrated in the sample below to add composite types to service operations.
      [DataContract]
      [KnownType(typeof(Employee))]
      public class Person
      {
          [DataMember]
          public string Fname { get; set; }
          [DataMember]
          public string Lname { get; set; }
      }
  
      [DataContract]
      public class Employee : Person
      {
          [DataMember]
          public int EmpId { get; set; }
          [DataMember]
          public string Desg { get; set; }
      }
  }
  
  namespace WCFTest
  {
      // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
      public class Service1
      {
          public List&lt;Employee&gt; GetData(int value)
          {
              EmployeeDetails ed = new EmployeeDetails();
              return ed.GetDetails();
          }
      }
  }
  </code></pre>
  
  <p>However I could see metadata is exposed in web.config.</p>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
   &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any clue where I am going wrong?</p>
  
  <p>EDIT: I think the reason behind the error is I am using a class as a service contract, now when I change it to an Interface, things work as expected, not sure why I am getting the error if I am specifying the class as service contract.</p>