CA2126: Type link demands require inheritance demands
Visual Studio 2012
|
TypeName |
TypeLinkDemandsRequireInheritanceDemands |
|
CheckId |
CA2126 |
|
Category |
Microsoft.Security |
|
Breaking Change |
Breaking |
A link demand on a method or its declaring type requires the immediate caller of the method to have the specified permission. An inheritance demand on a method requires an overriding method to have the specified permission. An inheritance demand on a type requires a deriving class to have the specified permission.
The following example shows a type that violates the rule.
using System; using System.Security.Permissions; namespace SecurityLibrary { [EnvironmentPermission(SecurityAction.LinkDemand, Read = "PATH")] public class TypesWithLinkDemands { public virtual void UnsecuredMethod() {} [EnvironmentPermission(SecurityAction.InheritanceDemand, Read = "PATH")] public virtual void SecuredMethod() { } } }