财产'PolicyEnforcement'是'ReadOnly'

时间:2016-02-18 15:35:40

标签: .net vb.net wcf

我正在尝试为

分配一个'Never'值

我正在尝试将ExtendedProtectionPolicy.PolicyEnforcement = Never分配给我的binding对象但我收到错误:

Error   1   Property 'PolicyEnforcement' is 'ReadOnly'. 

对象声明:

Dim binding As New WSHttpBinding()
binding.Name = "WSHttpBinding_ITest"
binding.ReaderQuotas.MaxStringContentLength = 10240
binding.ReliableSession.Enabled = True
binding.Security.Mode = SecurityMode.None
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None

'Error below binding.Security.Transport.ExtendedProtectionPolicy.PolicyEnforcement = System.Security.Authentication.ExtendedProtection.PolicyEnforcement.Never

有关如何为其分配“从不”值的任何想法吗?

1 个答案:

答案 0 :(得分:1)

由于ExtendedProtectionPolicy是不可变的,您需要将其替换为根据需要配置的新实例,而不是更新现有实例,例如。

binding.Security.Transport.ExtendedProtectionPolicy =
    New System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy(
        Syste‌​m.Security.Authentication.ExtendedProtection.PolicyEnforcement.Never
    )