简体   繁体   English

Azure中的WCF配置错误:无法识别的属性'protectTokens'。 在本地.NET 4环境中正常工作

[英]WCF config error in Azure: Unrecognized attribute 'protectTokens'. Works fine in on-premises .NET 4 environment

Our .Net 4 component accesses a third-party web service via a WCF client proxy. 我们的.Net 4组件通过WCF客户端代理访问第三方Web服务。 The WSDL for the third-party web service contains the Protect Tokens security policy: 第三方Web服务的WSDL包含“保护令牌”安全策略:

<sp:ProtectTokens />

Accordingly, the custom binding configuration generated by Visual Studio 2013 contains: 因此,Visual Studio 2013生成的自定义绑定配置包含:

protectTokens="true" 

We've been using this for some weeks in our on-premises environment without any issues. 我们已经在内部部署环境中使用了数周,没有任何问题。 However, on updating our Azure environment with this version of the app, we find it throws an exception: 但是,在使用此版本的应用程序更新Azure环境时,我们发现它引发了异常:

Unrecognized attribute 'protectTokens'.
Note that attribute names are case-sensitive

MSDN seems conflicted on what .NET version supports protectTokens. MSDN似乎在.NET版本支持protectTokens上发生冲突。 The linked page is headed .NET 4.6 and 4.5, but its footer states "Available since 3.0". 链接页面的标题为.NET 4.6和4.5,但其页脚注明“自3.0起可用”。 Regardless, the app is built for 4.0 and as I said, gives no error in the on-premises environment. 无论如何,该应用程序都是为4.0构建的,正如我所说,在本地环境中不会出现任何错误。

What is causing the error in Azure? 是什么导致Azure中的错误? This is OS Family 2 (2008R2). 这是OS系列2(2008R2)。

SecurityElementBase.ProtectTokens Property if only available in framework >= 4.5 如果仅在框架> = 4.5中可用,则为SecurityElementBase.ProtectTokens属性

You can check ProtectTokens documentation here 您可以在此处查看ProtectTokens文档

Full SecurityElementBase class properties for framework 4.5 , 4.6 (you can get ProtectTokens property) 框架4.5,4.6的完整SecurityElementBase类属性 (您可以获取ProtectTokens属性)

Full SecurityElementBase class properties for framework 4.0 (no such ProtectTokens property) 框架4.0的完整SecurityElementBase类属性 (没有此类ProtectTokens属性)

Whole Story 整个故事

msdn documentation bug. msdn文档错误。

I was digging into IL in the assemblies SecurityElementBase.dll for .net 4 and 4.5. 我在.net 4和4.5的程序集SecurityElementBase.dll中研究了IL。 and guess what indeed there's no ProtectTokens Property in .Net < 4.5 . 并猜测.Net <4.5中确实没有ProtectTokens属性。

  1. .Net 4 : C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.ServiceModel.dll .Net 4C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.ServiceModel.dll
  2. .Net 4.5 : C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\System.ServiceModel.dll .Net 4.5C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\System.ServiceModel.dll

You can verify it even more easily using VS2015 object explorer. 您可以使用VS2015对象资源管理器更轻松地进行验证。

System.ServiceModel.dll .NetFX 4 System.ServiceModel.dll .NetFX 4

System.ServiceModel.dll .net 4

System.ServiceModel.dll .NetFX 4.5 System.ServiceModel.dll .NetFX 4.5

System.ServiceModel.dll .net 4.5]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM