title: TransactionScope - The underlying provider failed on EnlistTransaction. MSDTC being aborted
body: <p>Our team have got a problem that manifests as:</p>
  
  <blockquote>
    <p>The underlying provider failed on EnlistTransaction; Cannot access a
    disposed object.Object name: 'Transaction'.</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/cUPcq.png" alt="enter image description here"></p>
  
  <p>which seemed to appear as soon as we began using <a href="http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx" rel="noreferrer">TransactionScope</a> to handle our applications' transactions.</p>
  
  <p>The top part of the stacktrace is captured as:</p>
  
  <blockquote>
    <p>at
    System.Data.EntityClient.EntityConnection.EnlistTransaction(Transaction transaction)
    at System.Data.Objects.ObjectContext.EnsureConnection()    at
    System.Data.Objects.ObjectContext.ExecuteStoreCommand(String commandText, Object[] parameters)
    at
    Reconciliation.Models.BillLines.BillLines.Reconciliation.Interfaces.IBillLineEntities.ExecuteStoreCommand(String, Object[])
    at
    Reconciliation.Models.Legacy.EntityDbEnvironment.ExecuteOracleSql(String sql)
    in EntityDbEnvironment.cs: line 41</p>
  </blockquote>
  
  <p>At the same time the MSDTC log is updated, which I've extracted using the <a href="http://blogs.msdn.com/b/distributedservices/archive/2009/02/07/the-hidden-tool-msdtc-transaction-tracing.aspx" rel="noreferrer">instructions here</a>:</p>
  
  <pre><code>pid=7060       ;tid=7908       ;time=04/29/2013-16:38:30.269   ;seq=136        ;eventid=TRANSACTION_BEGUN                        ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"transaction has begun, description :'&lt;NULL&gt;'"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:30.269   ;seq=137        ;eventid=RM_ENLISTED_IN_TRANSACTION               ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"resource manager #1002 enlisted as transaction enlistment #1. RM guid = 'defc4277-47a6-4cd9-b092-93a668e2097b'"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:31.658   ;seq=138        ;eventid=RECEIVED_ABORT_REQUEST_FROM_BEGINNER     ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"received request to abort the transaction from beginner"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:31.658   ;seq=139        ;eventid=TRANSACTION_ABORTING                     ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"transaction is aborting"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:31.658   ;seq=140        ;eventid=RM_ISSUED_ABORT                          ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"abort request issued to resource manager #1002 for transaction enlistment #1"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:31.658   ;seq=141        ;eventid=RM_ACKNOWLEDGED_ABORT                    ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"received acknowledgement of abort request from the resource manager #1002 for transaction enlistment #1"
  pid=7060       ;tid=7908       ;time=04/29/2013-16:38:31.658   ;seq=142        ;eventid=TRANSACTION_ABORTED                      ;tx_guid=60f6390c-7570-488a-97a9-2c3912c4ca3e     ;"TM Identifier='(null)                                            '" ;"transaction has been aborted"
  </code></pre>
  
  <p>As you can see an <strong>RECEIVED_ABORT_REQUEST_FROM_BEGINNER</strong> a second after <strong>RM_ENLISTED_IN_TRANSACTION</strong> was logged.</p>
  
  <p>We can't understand where this abort request originates from, or why it was raised.  The SQL causing the problem is a simple SELECT which we can execute without issue via our database client.</p>
  
  <p>The application works <em>most</em> of the time, only occasionally displaying this issue.</p>
  
  <p>We are using Oracle 10.2.0.5.0 with Entity Framework.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Following advice from @Astrotrain I set up the logging on System.Transactions.  The final entry produced is literally cut off half-way though:</p>
  
  <pre><code>....
  &lt;ApplicationData&gt;
  &lt;TraceData&gt;
  &lt;DataItem&gt;
  &lt;TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"&gt;
  &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/TransactionScopeCreated&lt;/TraceIdentifier&gt;
  &lt;Description&gt;TransactionScope Created&lt;/Description&gt;
  &lt;AppDomain&gt;BillLineGeneratorUI.exe&lt;/AppDomain&gt;
  &lt;ExtendedData xmlns="http://schemas.microsoft.com/2004/03/Transactions/TransactionScopeCreatedTraceRecord"&gt;
  &lt;TraceSource&gt;[Base]
  </code></pre>
  
  <p>As you can see the exception <em>actually prevents</em> the log finishing.  What can I learn from this? Any ideas?</p>