wcf的一個BUG(自訂行為拓展)

來源:互聯網
上載者:User

最近在學習WCF技術,在學習到WCF拓展時,發現一個奇怪的問題。

就是在使用自訂拓展元素時,如果按照下面的方式在設定檔註冊拓展元素(設定檔手寫):

<add name="ContextPropagationExtension" type="HXW.WCF.Extension.ContextPropagationBehaviorElement, HXW.WCF.Extension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

程式運行時會拋出一個異常:

未處理 System.Configuration.ConfigurationErrorsException
  Message="建立 system.serviceModel/behaviors 的配置節處理常式時出錯: 無法將擴充元素“ContextPropagationExtension”添加到此元素中。請驗證該擴充是否已在 system.serviceModel/extensions/behaviorExtensions 中的擴充集合中註冊。\r\n參數名: element (F:\\hxw\\wcf\\HXW.WCF\\HXW.WCF.Host\\bin\\Debug\\HXW.WCF.Host.vshost.exe.Config line 10)"

研究了兩天都解決不了。

最後google了才發現是微軟的BUG。具體看下面的連結:

https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=216431

具體解決方式如下:

把上面那段配置改為:

<add name="ContextPropagationExtension" type="HXW.WCF.Extension.ContextPropagationBehaviorElement,  HXW.WCF.Extension,  Version=1.0.0.0,  Culture=neutral,  PublicKeyToken=null" />

(就是在,後面加上一個空格)

就正常了。所以大家手寫設定檔一定要注意。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.