RunInstallerAttribute Classe

Definição

Especifica se o Instalador de Ação Personalizada do Visual Studio ou o Installutil.exe (Ferramenta de Instalação) deve ser invocado quando o assembly é instalado.

public ref class RunInstallerAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type RunInstallerAttribute = class
    inherit Attribute
Public Class RunInstallerAttribute
Inherits Attribute
Herança
RunInstallerAttribute
Atributos

Exemplos

O exemplo a seguir especifica que o instalador deve ser executado para 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

O próximo exemplo cria uma instância de MyProjectInstaller. Em seguida, ele obtém os atributos para a classe , extrai o RunInstallerAttributee imprime se o instalador deve ser executado.

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

Comentários

Se uma classe que herda de Installer for marcada com o definido como true, o RunInstallerAttribute Instalador de Ação Personalizada do Visual Studio ou o InstallUtil.exe será invocado quando o assembly estiver instalado. Os membros marcados com o RunInstallerAttribute definido como false não invocarão um instalador. O padrão é true.

Observação

Quando você marca uma propriedade com o RunInstallerAttribute definido como true, o valor desse atributo é definido como o membro Yesconstante . Para uma propriedade marcada com o RunInstallerAttribute definido como false, o valor é No. Portanto, quando você deseja marcar o valor desse atributo em seu código, você deve especificar o atributo como RunInstallerAttribute.Yes ou RunInstallerAttribute.No.

Para obter mais informações, consulte Atributos.

Construtores

RunInstallerAttribute(Boolean)

Inicializa uma nova instância da classe RunInstallerAttribute.

Campos

Default

Especifica a visibilidade padrão, que é No. Esse campo static é somente leitura.

No

Especifica que o Instalador de Ação Personalizada do Visual Studio ou o Installutil.exe (Ferramenta de Instalação) não deve ser invocado quando o assembly é instalado. Esse campo static é somente leitura.

Yes

Especifica que o Instalador de Ação Personalizada do Visual Studio ou o Installutil.exe (Ferramenta de Instalação) deve ser invocado quando o assembly é instalado. Esse campo static é somente leitura.

Propriedades

RunInstaller

Obtém um valor que indica se um instalador deve ser invocado durante a instalação de um assembly.

TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.

(Herdado de Attribute)

Métodos

Equals(Object)

Determina se o valor do RunInstallerAttribute especificado é equivalente ao RunInstallerAttribute atual.

GetHashCode()

Gera um código hash para o RunInstallerAttribute atual.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Determina se este atributo é o padrão.

Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.

(Herdado de Attribute)

Aplica-se a

Confira também