RunInstallerAttribute 类

定义

指定在安装程序集时是否应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)

C#
[System.AttributeUsage(System.AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
继承
RunInstallerAttribute
属性

示例

以下示例指定应为 MyProjectInstaller运行安装程序。

C#
[RunInstallerAttribute(true)]
 public class MyProjectInstaller : Installer {
    // Insert code here.
 }

下一个示例创建 的 MyProjectInstaller实例。 然后,它获取 类的属性,提取 RunInstallerAttribute,并打印是否运行安装程序。

C#
public static int Main() {
    // Creates a new installer.
    MyProjectInstaller myNewProjectInstaller = new MyProjectInstaller();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewProjectInstaller);
 
    /* Prints whether to run the installer by retrieving the 
     * RunInstallerAttribute from the AttributeCollection. */
    RunInstallerAttribute myAttribute = 
       (RunInstallerAttribute)attributes[typeof(RunInstallerAttribute)];
    Console.WriteLine("Run the installer? " + myAttribute.RunInstaller.ToString());
  
    return 0;
 }

注解

如果从 继承的 Installer 类标记为 RunInstallerAttribute 设置为 true,则安装程序集时,将调用 Visual Studio 的自定义操作安装程序或 InstallUtil.exe。 标记为 RunInstallerAttribute 的成员 false 设置为 不会调用安装程序。 默认为 true

备注

将 属性RunInstallerAttributetrue标记为 时,此属性的值设置为常量成员 Yes。 对于标记为 的 RunInstallerAttributefalse属性,设置为 ,值为 No。 因此,如果要在代码中检查此属性的值,则必须将属性指定为 RunInstallerAttribute.YesRunInstallerAttribute.No

有关更多信息,请参阅特性

构造函数

字段

Default

指定默认可见性,即 No。 此 static 字段是只读的。

No

指定在安装程序集时不应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此 static 字段是只读的。

Yes

指定在安装程序集时应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此 static 字段是只读的。

属性

RunInstaller

获取一个值,该值指示在程序集安装期间是否调用某安装程序。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

确定指定的 RunInstallerAttribute 的值是否与当前的 RunInstallerAttribute 等效。

GetHashCode()

生成当前 RunInstallerAttribute 的哈希代码。

GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

确定此特性是否为默认特性。

Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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
.NET Standard 2.0, 2.1

另请参阅