WCF中的Visual Studio 2010 Express中的TransactionFlow

问题描述

| 我正在尝试使用免费的Microsoft Visual Web Developer 2010 Express开始WCF中的事务。它为我提供了创建\“ WCF服务应用程序\”的选项,但似乎没有给我很多用于承载它或配置不同绑定的选项。如果我F5项目,我得到错误
At least one operation on the \'Service\' contract is configured with the TransactionFlowAttribute attribute set to Mandatory but the channel\'s binding \'BasicHttpBinding\' is not configured with a TransactionFlowBindingElement. The TransactionFlowAttribute attribute set to Mandatory cannot be used without a TransactionFlowBindingElement.
我尝试将ѭ1配置添加到web.config中,但它似乎只是被忽略了。我也尝试将认的启动应用程序更改为WcfSvcHost.exe,但此选项显示为灰色。我开始怀疑Express版本会出现一些故障,但我对自己只是笨蛋感到乐观。是我需要学习的技巧,还是在Visual Studio 2010的完整版上花光,足以让我克服这一障碍并进入下一个障碍? 谢谢!     

解决方法

        在不知道您的配置和服务合同的情况下,几乎不可能做出有针对性的回答。如果您认为配置被忽略,请确保在
service
endpoint/@contract
中使用的名称包含CLR命名空间。 WCF 4使用了不错的简化配置,恕我直言,真正的配置比以前复杂得多。您可以通过将默认值添加到您的网络配置中来切换默认值:
<protocolMapping>
  <remove scheme=\"http\" />
  <add scheme=\"http\" binding=\"wsHttpBinding\" bindingConfiguration=\"transactionFlowEnabled\"/>
</protocolMapping>
<bindings>
  <wsHttpBinding>
    <binding name=\"transactionFlowEnabled\" transactionFlow=\"true\" />
  </wsHttpBinding>
</bindings>
这是解决方法,应将定义的绑定用作默认值而不是“ 5”。     ,        感谢Ladislav的建议,我能够通过将以下条目添加到Web.config文件中来解决此问题:
<services>
  <service name=\"WcfService1.Service1\">
    <endpoint
      address=\"\"
      binding=\"wsHttpBinding\"
      contract=\"WcfService1.IService1\"
      />
  </service>
</services>
和:
<bindings>
  <wsHttpBinding>
    <binding transactionFlow=\"true\"/>
  </wsHttpBinding>
</bindings>