title: Hosting an wcf service into a website issue : System.ArgumentException: ServiceHost only supports class service types
body: <p>I have something like this:</p>
  
  <p><strong>MathServiceLibrary</strong> (WCF Service Library)</p>
  
  <pre><code>[ServiceContract]
  public interface IMathService
  {
          [OperationContract]
          int Add(int x, int y);
          [OperationContract]
          int Multiply(int x, int y);
  }
  
  public class MathService : IMathService
  {
          public int Add(int x, int y)
          {
              return x + y;
          } 
  
          public int Multiply(int x, int y)
          {
              return x * y;
          }
  }
  
  &lt;behaviors&gt;
     &lt;serviceBehaviors&gt;
        &lt;behavior name="defaultServiceBehavior"&gt;
           &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;/behavior&gt;
     &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;services&gt;
     &lt;service behaviorConfiguration="defaultServiceBehavior" 
              name="MathServiceLibrary.MathService"&gt;
         &lt;endpoint 
             address="mex" 
             binding="mexHttpBinding" 
             contract="IMetadataExchange" /&gt;
         &lt;endpoint 
             address="math" 
             binding="wsHttpBinding" 
             contract="MathServiceLibrary.IMathService" /&gt;
         &lt;host&gt;
            &lt;baseAddresses&gt;
               &lt;add baseAddress="http://localhost:8080/" /&gt;
            &lt;/baseAddresses&gt;
         &lt;/host&gt;
      &lt;/service&gt;
   &lt;/services&gt;
  </code></pre>
  
  <p>If I run this I can see the WCF Test Client and everything is ok.</p>
  
  <p>Now I want to host this service into IIS so I create a web site and add a reference to <code>MathServiceLibrary</code>.</p>
  
  <p>I have this <code>ms.svc</code></p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" 
      Service="MathServiceLibrary.IMathService" %&gt; 
  </code></pre>
  
  <p>and this <code>web.config</code></p>
  
  <pre><code>    &lt;system.serviceModel&gt;
          &lt;services&gt;
              &lt;service behaviorConfiguration="defaultServiceBehavior" name="MathServiceLibrary.MathService"&gt;
                  &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
                  &lt;endpoint address="" binding="wsHttpBinding" contract="MathServiceLibrary.IMathService"&gt;
                      &lt;identity&gt;
                          &lt;dns value="localhost"/&gt;
                      &lt;/identity&gt;
                  &lt;/endpoint&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="defaultServiceBehavior"&gt;
                      &lt;serviceMetadata httpGetEnabled="true"/&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
      &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>When I right click on <code>ms.svc</code> view in browser I get this:</p>
  
  <blockquote>
    <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.</p>
    
    <p>Exception Details: System.ArgumentException: ServiceHost only supports class service types.</p>
    
    <p>Source Error:</p>
    
    <p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace:</p>
    
    <p>[ArgumentException: ServiceHost only supports class service types.]<br>
    System.ServiceModel.Description.ServiceDescription.GetService(Type
    serviceType) +12229075<br>
    System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2&amp;
    implementedContracts) +55<br>
    System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection
    baseAddresses) +154<br>
    System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49<br>
    System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151<br>
    System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type
    serviceType, Uri[] baseAddresses) +30<br>
    System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String 
    constructorString, Uri[] baseAddresses) +420<br>
    System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440<br>
    System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44<br>
    System.ServiceModel.HostingManager.EnsureServiceAvailable(String
    normalizedVirtualPath) +615  </p>
    
    <p>[ServiceActivationException: The service '/MathWebSite/ms.svc' cannot be activated due to an exception during compilation. The
    exception message is: ServiceHost only supports class service types..]<br>
    System.Runtime.AsyncResult.End(IAsyncResult result) +679246<br>
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
    result) +190<br>
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
    context, String routeServiceVirtualPath, Boolean flowContext, Boolean 
    ensureWFService) +234<br>
    System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355<br>
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +148<br>
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75  </p>
  </blockquote>
  
  <p>I can't figure out what I am missing.</p>