Condividi tramite


RunInstallerAttribute Classe

Definizione

Specifica se all'installazione dell'assembly verrà chiamato Installutil.exe (strumento Installer) o il programma di installazione delle azioni personalizzate di Visual Studio.

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
Ereditarietà
RunInstallerAttribute
Attributi

Esempio

Nell'esempio seguente viene specificato che il programma di installazione deve essere eseguito per 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

Nell'esempio seguente viene creata un'istanza di MyProjectInstaller. Ottiene quindi gli attributi per la classe , estrae RunInstallerAttributee stampa se eseguire il programma di installazione.

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

Commenti

Se una classe che eredita da Installer viene contrassegnata con il RunInstallerAttribute set su true, il programma di installazione azioni personalizzate di Visual Studio o il InstallUtil.exe verrà richiamato quando viene installato l'assembly. I membri contrassegnati con il RunInstallerAttribute set su false non richiameranno un programma di installazione. Il valore predefinito è true.

Nota

Quando si contrassegna una proprietà con l'oggetto RunInstallerAttribute impostato su true, il valore di questo attributo viene impostato sul membro Yescostante . Per una proprietà contrassegnata con l'oggetto RunInstallerAttribute impostato su false, il valore è No. Pertanto, quando si vuole controllare il valore di questo attributo nel codice, è necessario specificare l'attributo come RunInstallerAttribute.Yes o RunInstallerAttribute.No.

Per altre informazioni, vedere Attributi.

Costruttori

Nome Descrizione
RunInstallerAttribute(Boolean)

Inizializza una nuova istanza della classe RunInstallerAttribute.

Campi

Nome Descrizione
Default

Specifica la visibilità predefinita, uguale a No. Questo campo static è di sola lettura.

No

Specifica che all'installazione dell'assembly non verrà chiamato Installutil.exe (strumento Installer) o il programma di installazione delle azioni personalizzate di Visual Studio. Questo campo static è di sola lettura.

Yes

Specifica che all'installazione dell'assembly verrà chiamato Installutil.exe (strumento Installer) o il programma di installazione delle azioni personalizzate di Visual Studio. Questo campo static è di sola lettura.

Proprietà

Nome Descrizione
RunInstaller

Ottiene un valore che indica se è necessario richiamare un programma di installazione durante l'installazione di un assembly.

TypeId

Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.

(Ereditato da Attribute)

Metodi

Nome Descrizione
Equals(Object)

Determina se il valore dell'attributo RunInstallerAttribute specificato è equivalente all'attributo RunInstallerAttribute corrente.

GetHashCode()

Genera un codice hash per l'oggetto RunInstallerAttribute corrente.

GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

Determina se questo attributo è predefinito.

Match(Object)

Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

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

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da Attribute)

Si applica a

Vedi anche