文章目錄
問題
當在 Windows 7 上用 VS2008 開發 WCF 3.5 用戶端程式時,VS 將在自動產生的設定檔的 xxxBinding/security/transport 節中插入
<extendedProtectionPolicy policyEnforcement="Never" />
如果將此程式部署到其他動作系統將報錯:無法識別的元素“extendedProtectionPolicy” (Unrecognized element extendedProtectionPolicy)。
原因
這是一個已知的問題,僅存在 Windows 7 系統上,似乎 Windows 7 對 .NET 3.5 的特殊擴充,但其他早期版本作業系統又不支援,下面是來自 WCF Team 的解釋:
Thank you for contacting us with your question.
Windows 7 has an additional security feature called Extended Protection. When you create an app.config for a client from the Windows 7 service, the tag "extendedProtectionPolicy" will be present in the app.config. When deploying the client to versions of Windows prior to Windows 7, this tag will not be valid. This is a known issue. This tag is not actually used by the client, so simply remove the tag. We will try to update future versions of .Net 3.5 to not include this tag in the generated app.config.
Thanks,
WCF Team
解決方案
直接移除這個節點即可。
這個問題在 .NET 4.0 已經被解決,不會再自動添加這個節點。
FW:WCF 錯誤: 無法識別的元素“extendedProtectionPolicy”
--------------------------------------------------------------------
new SearchBestBetClient(EndpointConfigurationName, adminServicesSettings.AdminServiceUrl)
'new SearchBestBetClient(EndpointConfigurationName, adminServicesSettings.AdminServiceUrl)' threw an exception of type 'System.Configuration.ConfigurationErrorsException'
base {System.Configuration.ConfigurationException}: {"Unrecognized element 'extendedProtectionPolicy'. (C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\8090\\web.config line 312)"}
BareMessage: "Unrecognized element 'extendedProtectionPolicy'."
Errors: {System.Configuration.ConfigurationException[0x00000001]}
Filename: "C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\8090\\web.config"
Line: 0x00000138
Message: "Unrecognized element 'extendedProtectionPolicy'. (C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\8090\\web.config line 312)"