RunInstallerAttribute 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定在安装程序集时是否应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。
public ref class RunInstallerAttribute : Attribute[System.AttributeUsage(System.AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute[<System.AttributeUsage(System.AttributeTargets.Class)>]
type RunInstallerAttribute = class
    inherit AttributePublic Class RunInstallerAttribute
Inherits Attribute- 继承
- 属性
示例
以下示例指定应为 MyProjectInstaller运行安装程序。
[RunInstallerAttribute(true)]
ref class MyProjectInstaller: public Installer{
   // Insert code here.
};
[RunInstallerAttribute(true)]
 public class MyProjectInstaller : Installer {
    // Insert code here.
 }
<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer
    ' Insert code here.
End Class
下一个示例创建 的 MyProjectInstaller实例。 然后,它获取 类的属性,提取 RunInstallerAttribute,并打印是否运行安装程序。
int main()
{
   // Creates a new installer.
   MyProjectInstaller^ myNewProjectInstaller = gcnew 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 = dynamic_cast<RunInstallerAttribute^>(attributes[ RunInstallerAttribute::typeid ]);
   Console::WriteLine( "Run the installer? {0}", myAttribute->RunInstaller );
   return 0;
}
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;
 }
Public Shared Function Main() As Integer
    ' Creates a new installer.
    Dim myNewProjectInstaller As New MyProjectInstaller()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewProjectInstaller)
    
    ' Prints whether to run the installer by retrieving the
    ' RunInstallerAttribute from the AttributeCollection. 
    Dim myAttribute As RunInstallerAttribute = _
        CType(attributes(GetType(RunInstallerAttribute)), RunInstallerAttribute)
    Console.WriteLine(("Run the installer? " & myAttribute.RunInstaller.ToString()))
    Return 0
End Function 'Main
注解
如果从 继承的 Installer 类标记为 RunInstallerAttribute 设置为 true,则安装程序集时,将调用 Visual Studio 的自定义操作安装程序或 InstallUtil.exe。 标记为 RunInstallerAttribute 的成员 false 设置为 不会调用安装程序。 默认为 true。
注意
将 属性RunInstallerAttributetrue标记为 时,此属性的值设置为常量成员 Yes。 对于标记为 的 RunInstallerAttributefalse属性,设置为 ,值为 No。 因此,如果要在代码中检查此属性的值,则必须将属性指定为 RunInstallerAttribute.Yes 或 RunInstallerAttribute.No。
有关更多信息,请参阅特性。
构造函数
| RunInstallerAttribute(Boolean) | 初始化 RunInstallerAttribute 类的新实例。 | 
字段
| Default | 指定默认可见性,即 No。 此  | 
| No | 指定在安装程序集时不应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此  | 
| Yes | 指定在安装程序集时应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此  | 
属性
| 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) |