System.Security.Permissions.HostProtectionAttribute Class

Allows the use of declarative security actions to determine host protection requirements. This class cannot be inherited.

See Also: HostProtectionAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Delegate | System.AttributeTargets.All, AllowMultiple=true, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class HostProtectionAttribute : CodeAccessSecurityAttribute

Remarks

This attribute affects only unmanaged applications that host the common language runtime and implement host protection, such as SQL Server. If the code is run in a client application or on a server that is not host-protected, the attribute "evaporates"; it is not detected and therefore not applied. When applied, the security action results in the creation of a link demand based on the host resources the class or method exposes.

Note:

The purpose of this attribute is to enforce host-specific programming model guidelines, not security behavior. Although a link demand is used to check for conformance to programming model requirements, the System.Security.Permissions.HostProtectionAttribute is not a security permission.

If the host does not have programming model requirements, the link demands do not occur.

This attribute identifies the following:

Note:

If you are creating a class library that is to be called by applications that may execute in a host protected environment, you should apply this attribute to members that expose System.Security.Permissions.HostProtectionResource resource categories. The .NET Framework class library members with this attribute cause only the immediate caller to be checked. Your library member must also cause a check of its immediate caller in the same manner.

Note:

Do not use the Native Image Generator (Ngen.exe) to create a native image of assemblies that are protected by the System.Security.Permissions.HostProtectionAttribute. In a full-trust environment, the image is always loaded, without regard to the System.Security.Permissions.HostProtectionAttribute, and in a partial-trust environment the image is not loaded.

Requirements

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0