HostProtectionAttribute Class

 

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

Namespace:   System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

System.Object
  System.Attribute
    System.Security.Permissions.SecurityAttribute
      System.Security.Permissions.CodeAccessSecurityAttribute
        System.Security.Permissions.HostProtectionAttribute

[<Sealed>]
[<SerializableAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Delegate,
    AllowMultiple = true, Inherited = false)>]
[<ComVisibleAttribute(true)>]
type HostProtectionAttribute = 
    class
        inherit CodeAccessSecurityAttribute
    end

NameDescription
System_CAPS_pubmethodHostProtectionAttribute()

Initializes a new instance of the HostProtectionAttribute class with default values.

System_CAPS_pubmethodHostProtectionAttribute(SecurityAction)

Initializes a new instance of the HostProtectionAttribute class with the specified SecurityAction value.

NameDescription
System_CAPS_pubpropertyAction

Gets or sets a security action.(Inherited from SecurityAttribute.)

System_CAPS_pubpropertyExternalProcessMgmt

Gets or sets a value indicating whether external process management is exposed.

System_CAPS_pubpropertyExternalThreading

Gets or sets a value indicating whether external threading is exposed.

System_CAPS_pubpropertyMayLeakOnAbort

Gets or sets a value indicating whether resources might leak memory if the operation is terminated.

System_CAPS_pubpropertyResources

Gets or sets flags specifying categories of functionality that are potentially harmful to the host.

System_CAPS_pubpropertySecurityInfrastructure

Gets or sets a value indicating whether the security infrastructure is exposed.

System_CAPS_pubpropertySelfAffectingProcessMgmt

Gets or sets a value indicating whether self-affecting process management is exposed.

System_CAPS_pubpropertySelfAffectingThreading

Gets or sets a value indicating whether self-affecting threading is exposed.

System_CAPS_pubpropertySharedState

Gets or sets a value indicating whether shared state is exposed.

System_CAPS_pubpropertySynchronization

Gets or sets a value indicating whether synchronization is exposed.

System_CAPS_pubpropertyTypeId

When implemented in a derived class, gets a unique identifier for this Attribute.(Inherited from Attribute.)

System_CAPS_pubpropertyUI

Gets or sets a value indicating whether the user interface is exposed.

System_CAPS_pubpropertyUnrestricted

Gets or sets a value indicating whether full (unrestricted) permission to the resource protected by the attribute is declared.(Inherited from SecurityAttribute.)

NameDescription
System_CAPS_pubmethodCreatePermission()

Creates and returns a new host protection permission.(Overrides SecurityAttribute.CreatePermission().)

System_CAPS_pubmethodEquals(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Returns a value that indicates whether this instance is equal to a specified object.(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

Returns the hash code for this instance.(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object)

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.(Inherited from Attribute.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Maps a set of names to a corresponding set of dispatch identifiers.(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can be used to get the type information for an interface.(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.GetTypeInfoCount(UInt32)

Retrieves the number of type information interfaces that an object provides (either 0 or 1).(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.(Inherited from Attribute.)

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.

System_CAPS_importantImportant

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 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:

  • Methods or classes that do not fit the host programming model, but are otherwise benign.

  • Methods or classes that do not fit the host programming model and could lead to destabilizing server-managed user code.

  • Methods or classes that do not fit the host programming model and could lead to a destabilization of the server process itself.

System_CAPS_noteNote

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 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.

System_CAPS_noteNote

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

The following code example illustrates the use of the HostProtectionAttribute attribute with a variety of HostProtectionResource values.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: