title: AspNetCompatibilityRequirement error when hosting a WCF service with AppFabric Endpoint in SharePoint 2010
body: <p>I am trying to host a WCF service within SharePoint 2010 with an AppFabric endpoint.  I am using the basicHttpRelayBinding.  When I host the service with a standard endpoint using the basicHttpBinding (not a service bus endpoint), the service works fine.  However, as soon as I add the endpoint using the basicHttpRelayBinding, I receive the following error in the event log and the service does not register with the service bus.</p>
  
  <p>WebHost failed to process a request.
   Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/58154627
   Exception: System.ServiceModel.ServiceActivationException: The service '/_vti_bin/FirstServiceFarmSolution/ListAccessService.svc' cannot be activated due to an exception during compilation.  The exception message is: The ChannelDispatcher at 'sb://cliffwahl-trial.servicebus.windows.net/ListAccessService' with contract(s) '"IListAccessService"' is unable to open its IChannelListener.. ---> System.InvalidOperationException: The ChannelDispatcher at 'sb://cliffwahl-trial.servicebus.windows.net/ListAccessService' with contract(s) '"IListAccessService"' is unable to open its IChannelListener. ---> System.InvalidOperationException: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.
     at System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase)</p>
  
  <p>I have tried the ws2007HttpRelayBinding and netTcpRelayBinding with the same behavior.</p>
  
  <p>Here are the pertinent parts of code:</p>
  
  <pre><code>[ServiceContract]
  public interface IListAccessService
  {
      [OperationContract]
      List&lt;Lead&gt; GetLeads();
  }
  
  [BasicHttpBindingServiceMetadataExchangeEndpoint]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class ListAccessService : IListAccessService
  </code></pre>
  
  <p>Service File:</p>
  
  <pre><code>&lt;%@ ServiceHost Debug="true" 
              Language="C#" 
              CodeBehind="ListAccessService.cs" 
              Service="FirstServiceFarmSolution.Code.ListAccessService, FirstServiceFarmSolution,Version=1.0.0.0,Culture=neutral,PublicKeyToken=625bdee8db8847ef" %&gt;
  </code></pre>
  
  <p>Web Config:</p>
  
  <pre><code>&lt;configuration&gt;   
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;clear/&gt;
        &lt;service name="FirstServiceFarmSolution.Code.ListAccessService"
  
                 behaviorConfiguration="ListAccessServiceBehavior"&gt;
          &lt;endpoint name="BasicHttpEndPoint"
                    address=""
                    binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBindingConfig"
                    contract="FirstServiceFarmSolution.Code.IListAccessService"&gt;
            &lt;identity&gt;
              &lt;dns value="sp2010" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;endpoint name="RelayEndPoint" 
                    address="https://cliffwahl-trial.servicebus.windows.net/ListAccessService"
                    binding="basicHttpRelayBinding"
                    bindingConfiguration="HttpRelayBindingConfig"
                    behaviorConfiguration="sharedSecretClientCredentials"
                    contract="FirstServiceFarmSolution.Code.IListAccessService" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBindingConfig" /&gt;
        &lt;/basicHttpBinding&gt;
        &lt;basicHttpRelayBinding&gt;
          &lt;binding name="HttpRelayBindingConfig"&gt;
            &lt;security relayClientAuthenticationType="None" mode="Transport"/&gt;
          &lt;/binding&gt;
        &lt;/basicHttpRelayBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="ListAccessServiceBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="false" httpsHelpPageEnabled="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="sharedSecretClientCredentials"&gt;
            &lt;transportClientEndpointBehavior credentialType="SharedSecret"&gt;
              &lt;clientCredentials&gt;
                &lt;sharedSecret issuerName="&lt;my issuer name&gt;" issuerSecret="&lt;my issuer secret&gt;"/&gt;
              &lt;/clientCredentials&gt;
            &lt;/transportClientEndpointBehavior&gt;
            &lt;serviceRegistrySettings discoveryMode="Public" /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;      
    &lt;/system.serviceModel&gt; 
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Does anyone see an issue with the setup or can someone point me to a SharePoint specific example of hosting a WCF service with a service bus endpoint?</p>
  
  <p>Thanks,
  Cliff</p>