HostProtectionAttribute.Resources 属性

定义

获取或设置标志,这些标志指定可能对宿主有害的功能类别。

C#
public System.Security.Permissions.HostProtectionResource Resources { get; set; }

属性值

HostProtectionResource 值的按位组合。 默认值为 None

示例

下面的代码示例演示如何将 特性与 属性一 HostProtectionAttribute 起使用 Resources 。 此示例是为 类提供的更大示例的一 HostProtectionAttribute 部分。

C#
// Use the enumeration flags to indicate that this method exposes 
// shared state and self-affecting process management.
// Either of the following attribute statements can be used to set the
// resource flags.
[HostProtectionAttribute(SharedState = true, 
    SelfAffectingProcessMgmt = true)]
[HostProtectionAttribute(Resources = HostProtectionResource.SharedState |
     HostProtectionResource.SelfAffectingProcessMgmt)]
private static void Exit(string Message, int Code)
{
    // Exit the sample when an exception is thrown.
    Console.WriteLine("\nFAILED: " + Message + " " + Code.ToString());
    Environment.ExitCode = Code;
    Environment.Exit(Code);
}

注解

标志 HostProtectionResource 指定方法或类公开的资源,这些资源可能对主机有害。

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另请参阅