RunInstallerAttribute Class
Assembly: System (in system.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Class)> _ Public Class RunInstallerAttribute Inherits Attribute 'Usage Dim instance As RunInstallerAttribute
/** @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.
Note: |
|---|
| 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 Inherits Installer ' Insert code here. End Class 'MyProjectInstaller
/** @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 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
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
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.
Note: