Namespace:
System.ComponentModel
Assembly:
System (in System.dll)
Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public Class RunInstallerAttribute _
Inherits Attribute
Dim instance As RunInstallerAttribute
[AttributeUsageAttribute(AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)]
public ref class RunInstallerAttribute : public Attribute
public class RunInstallerAttribute extends Attribute
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
[RunInstallerAttribute(true)]
public class MyProjectInstaller : Installer {
// Insert code here.
}
[RunInstallerAttribute(true)]
ref class MyProjectInstaller: public Installer{
// Insert code here.
};
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 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;
}
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;
}
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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Reference