0

Our .Net 4 component accesses a third-party web service via a WCF client proxy. The WSDL for the third-party web service contains the Protect Tokens security policy:

<sp:ProtectTokens />

Accordingly, the custom binding configuration generated by Visual Studio 2013 contains:

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:

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

MSDN seems conflicted on what .NET version supports protectTokens. The linked page is headed .NET 4.6 and 4.5, but its footer states "Available since 3.0". Regardless, the app is built for 4.0 and as I said, gives no error in the on-premises environment.

What is causing the error in Azure? This is OS Family 2 (2008R2).

Reg Edit
  • 6,719
  • 1
  • 35
  • 46

1 Answers1

0

SecurityElementBase.ProtectTokens Property if only available in framework >= 4.5

You can check ProtectTokens documentation here

Full SecurityElementBase class properties for framework 4.5 , 4.6 (you can get ProtectTokens property)

Full SecurityElementBase class properties for framework 4.0 (no such ProtectTokens property)

Whole Story

msdn documentation bug.

I was digging into IL in the assemblies SecurityElementBase.dll for .net 4 and 4.5. and guess what indeed there's no ProtectTokens Property in .Net < 4.5 .

  1. .Net 4: C:\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

You can verify it even more easily using VS2015 object explorer.

System.ServiceModel.dll .NetFX 4

System.ServiceModel.dll .net 4

System.ServiceModel.dll .NetFX 4.5

System.ServiceModel.dll .net 4.5]

JuanK
  • 2,056
  • 19
  • 32
  • This doesn't seem to be the whole story though. As I said, MSDN gives conflicting information. And the idea that protectTokens is not supported in .NET Framework 4 itself conflicts with the fact that protectTokens was generated, and works in the on-premises environment, in an app that specifically targets .NET Framework 4. – Reg Edit Dec 15 '15 at 13:42
  • @RegEdit I have added more details verifying directly into assemblies. – JuanK Dec 16 '15 at 16:45
  • This does not answer the question. – Reg Edit Jan 03 '16 at 09:52