RunInstallerAttribute 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定在安装程序集时是否应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。
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
- 继承
- 属性
以下示例指定应为 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
下一个示例创建 的 MyProjectInstaller
实例。 然后,它获取 类的属性,提取 RunInstallerAttribute,并打印是否运行安装程序。
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
如果从 继承的 Installer 类标记为 RunInstallerAttribute 设置为 true
,则安装程序集时,将调用 Visual Studio 的自定义操作安装程序或 InstallUtil.exe。 标记为 RunInstallerAttribute 的成员 false
设置为 不会调用安装程序。 默认为 true
。
备注
将 属性RunInstallerAttributetrue
标记为 时,此属性的值设置为常量成员 Yes。 对于标记为 的 RunInstallerAttributefalse
属性,设置为 ,值为 No。 因此,如果要在代码中检查此属性的值,则必须将属性指定为 RunInstallerAttribute.Yes 或 RunInstallerAttribute.No。
有关更多信息,请参阅特性。
Default |
指定默认可见性,即 No。 此 |
No |
指定在安装程序集时不应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此 |
Yes |
指定在安装程序集时应调用 Visual Studio 自定义操作安装程序或 Installutil.exe (安装程序工具)。 此 |
Run |
获取一个值,该值指示在程序集安装期间是否调用某安装程序。 |
Type |
在派生类中实现时,获取此 Attribute 的唯一标识符。 (继承自 Attribute) |
Equals(Object) |
确定指定的 RunInstallerAttribute 的值是否与当前的 RunInstallerAttribute 等效。 |
Get |
生成当前 RunInstallerAttribute 的哈希代码。 |
Get |
获取当前实例的 Type。 (继承自 Object) |
Is |
确定此特性是否为默认特性。 |
Match(Object) |
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
_Attribute. |
将一组名称映射为对应的一组调度标识符。 (继承自 Attribute) |
_Attribute. |
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 (继承自 Attribute) |
_Attribute. |
检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute) |
_Attribute. |
提供对某一对象公开的属性和方法的访问。 (继承自 Attribute) |
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |