Export (0) Print
Expand All

RunInstallerAttribute Class

Specifies whether the Visual Studio Custom Action Installer or the Installer Tool (Installutil.exe) should be invoked when the assembly is installed.

Namespace: System.ComponentModel
Assembly: System (in system.dll)

[AttributeUsageAttribute(AttributeTargets.Class)] 
public class RunInstallerAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public class RunInstallerAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public class RunInstallerAttribute extends Attribute
Not applicable.

If a class that inherits from Installer is marked with the RunInstallerAttribute set to true, Visual Studio's Custom Action Installer or the InstallUtil.exe will be invoked when the assembly is installed. Members marked with the RunInstallerAttribute set to false will not invoke an installer. The default is false.

NoteNote:

When you mark a property with the RunInstallerAttribute set to true, the value of this attribute is set to the constant member Yes. For a property marked with the RunInstallerAttribute set to false, the value is No. Therefore, when you want to check the value of this attribute in your code, you must specify the attribute as RunInstallerAttribute.Yes or RunInstallerAttribute.No.

For more information, see Attributes Overview and Extending Metadata Using Attributes.

The following example specifies that the installer should be run for MyProjectInstaller.

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

/** @attribute RunInstallerAttribute(true)
 */
public static class MyProjectInstaller extends Installer
{
    // Insert code here.
} //MyProjectInstaller

The next example creates an instance of MyProjectInstaller. Then it gets the attributes for the class, extracts the RunInstallerAttribute, and prints whether to run the installer.

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 static void main(String[] args)
{
    // 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.get_Item(
        RunInstallerAttribute.class.ToType())));

    Console.WriteLine(("Run the installer? " 
        + System.Convert.ToString(myAttribute.get_RunInstaller())));
} //main

System.Object
   System.Attribute
    System.ComponentModel.RunInstallerAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft