C# WCF服务中的TransactionScope异常

C# WCF服务中的TransactionScope异常,c#,web-services,wcf,transactionscope,nettcpbinding,C#,Web Services,Wcf,Transactionscope,Nettcpbinding,我正在尝试在wcf服务中启用事务流 但是,我得到以下错误: The header 'OleTxTransaction' from the namespace 'http://schemas.microsoft.com/ws/2006/02/tx/oletx' was not understood by the recipient of this message, causing the message to not be processed. This error typically in

我正在尝试在wcf服务中启用事务流

但是,我得到以下错误:

  The header 'OleTxTransaction' from the namespace 'http://schemas.microsoft.com/ws/2006/02/tx/oletx' was not understood by the recipient of this message, causing the message to not be processed.  This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding. 
这是我正在尝试运行的代码的代码片段:

var transactionOptions = new TransactionOptions
                                 {
                                     IsolationLevel = IsolationLevel.ReadCommitted
                                 };

using (var transaction = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
        {
            try
            {
                var company = CreateCompanyDto(settings);

                if (settings.Institution.CompletedSetup)
                {
                    _ezFinanceCompanyServiceLibrary.UpdateCompany(company); // This is the wcf call.
                }
                else
                {
                   _ezFinanceCompanyServiceLibrary.CreateCompany(company); // This is the wcf call.
                    CreateDefaultInventroyItems(company.EntityGuid);
                }

                _db.SaveChanges();
                transaction.Complete();

                return true;
            }
            catch (Exception exception)
            {
                _log.Error(exception.Message);
                return false;
            }
        }
这是我在web api的web.config上的绑定选项

<bindings>
  <netTcpBinding>
    <binding name="netTcpBindingbehavior" transactionFlow="true" portSharingEnabled="true" />
  </netTcpBinding>
  <netMsmqBinding>
    <binding name="netMsmqBinding">
      <security mode="None" />
    </binding>
  </netMsmqBinding>
</bindings>
我的公开方法具有以下属性

[OperationBehavior(TransactionScopeRequired = true)]
wcf服务中App.config上的My bindings选项

<bindings>
  <netTcpBinding>
    <binding name="netTcpBinding" transactionFlow="true" portSharingEnabled="true" />
  </netTcpBinding>
</bindings>
在服务和web api上


似乎无法找出问题所在。

结果是,WCF方法调用的方法上放置了
[OperationContract]
属性,这些方法已具有
[OperationContract]
删除所有
[OperationContract]
属性,只将它们放在WCF公开的方法上,就解决了问题

<bindings>
  <netTcpBinding>
    <binding name="netTcpBinding" transactionFlow="true" portSharingEnabled="true" />
  </netTcpBinding>
</bindings>
transactionProtocol="OleTransactions"