title: The service operation requires a transaction to be flowed
body: <p>I am facing strange issue with our WCF service. The same code was working fine until recently we added more OperationContracts(Web Methods). </p>
  
  <p>We have common 3 tier architecture.</p>
  
  <ul>
  <li>DAL (WCF) </li>
  <li>BLL</li>
  <li>Web UI</li>
  </ul>
  
  <p>Here is my quick sample code:</p>
  
  <p>DAL (WCF):</p>
  
  <pre><code>[ServiceContract]
  interface IPerson
  {
     [OperationContract]
     [TransactionFlow(TransactionFlowOption.Mandatory)]
     int AddPerson(Person p);
  }
  
  
  // AddPerson is implemented in the service
  [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
  public int AddPerson(Person p)
  {
    // LINQ DataContext stuff goes here
  }
  </code></pre>
  
  <p>BLL: </p>
  
  <pre><code>public class EmployeeBLL 
  {
     public void AddNewEmployee(Person p)
     {
         using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
              {
                  try
                  {
                     PersonClient perClient = new PersonClient();
                     int personId = perClient.AddPerson(p);
                     ts.Complete();
                  }
                  catch (Exception ex)
                  {
                     // Log exception
                  }
                  finally
                  {
                      ts.Dispose();
                  }
              }
              perClient.Close();
     }
  }
  </code></pre>
  
  <p>Usage in Web UI:</p>
  
  <pre><code>EmployeeBLL empBLL = new EmployeeBLL ()
  empBLL.AddNewEmployee(person);
  </code></pre>
  
  <p>I get "The service operation requires a transaction to be flowed." in my BLL when trying to call AddPerson method in service. Not much luck after enabling tracing in web.config.</p>
  
  <p>Detailed Stack Trace:</p>
  
  <pre><code>Server stack trace: 
     at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
     at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
  
  Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
  </code></pre>
  
  <p>Client Configuration:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="WSHttpBinding_IEmployee" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="true" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="5000000"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false"&gt;
            &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
            &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" /&gt;
            &lt;security mode="Message"&gt;
              &lt;transport clientCredentialType="Windows" proxyCredentialType="None"
                  realm="" /&gt;
              &lt;message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:2882/Test.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEmployee"
            contract="Test.IEmployee" name="WSHttpBinding_IEmployee"&gt;
          &lt;identity&gt;
            &lt;dns value="localhost" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>