RunInstallerAttribute Classe

Definição

Especifica se o instalador de ação personalizada Visual Studio ou o Installutil.exe (Ferramenta do Instalador) 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 exemplo a seguir cria uma instância de MyProjectInstaller. Em seguida, ele obtém os atributos da 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 RunInstallerAttribute definido como true, o Instalador de Ação Personalizada do Visual Studio ou o InstallUtil.exe serão invocados quando o assembly for instalado. Os membros marcados com o RunInstallerAttribute conjunto a false não invocarão um instalador. O padrão é true.

Note

Quando você marca uma propriedade com o RunInstallerAttribute conjunto como true, o valor desse atributo é definido como o membro Yesconstante. Para uma propriedade marcada com o RunInstallerAttribute conjunto como false, o valor é No. Portanto, quando você deseja verificar 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

Nome Description
RunInstallerAttribute(Boolean)

Inicializa uma nova instância da classe RunInstallerAttribute.

Campos

Nome Description
Default

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

No

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

Yes

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

Propriedades

Nome Description
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 esse Attribute.

(Herdado de Attribute)

Métodos

Nome Description
Equals(Object)

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

GetHashCode()

Gera um código hash para o atual RunInstallerAttribute.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Determina se esse 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 Objectatual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

Nome Description
_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 de um objeto, que podem ser usadas para obter as informações de tipo de 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