RunInstallerAttribute 類別

定義

規定安裝組件時應呼叫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
繼承
RunInstallerAttribute
屬性

範例

以下範例指定安裝程式應執行於 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 的類別被標記為 RunInstallerAttributetrue,安裝組裝時會啟動 Visual Studio 的自訂動作安裝程式或 InstallUtil.exe。 標記為 RunInstallerAttributefalse 成員將不會呼叫安裝程式。 預設值為 true

Note

當你將屬性標記為 RunInstallerAttributetrue時,該屬性的值會被設定為常數成員 Yes。 對於標記為 RunInstallerAttributefalse屬性,值為 No。 因此,當你想檢查程式碼中這個屬性的值時,必須指定為 RunInstallerAttribute.YesRunInstallerAttribute.No

如需詳細資訊,請參閱屬性

建構函式

名稱 Description
RunInstallerAttribute(Boolean)

初始化 RunInstallerAttribute 類別的新執行個體。

欄位

名稱 Description
Default

指定預設的可見性,也就是 No。 此 static 欄位為唯讀。

No

規定安裝組件時不應呼叫Visual Studio自訂動作安裝程式或Installutil.exe(安裝工具)。 此 static 欄位為唯讀。

Yes

規定安裝組件時應呼叫Visual Studio自訂動作安裝程式或 Installutil.exe(安裝工具)。 此 static 欄位為唯讀。

屬性

名稱 Description
RunInstaller

會獲得一個值,指示安裝組件時是否應呼叫安裝程式。

TypeId

在衍生類別中實作時,取得這個 Attribute的唯一標識碼。

(繼承來源 Attribute)

方法

名稱 Description
Equals(Object)

判斷指定的 RunInstallerAttribute 值是否等同於電流 RunInstallerAttribute

GetHashCode()

產生當前 RunInstallerAttribute的雜湊碼。

GetType()

取得目前實例的 Type

(繼承來源 Object)
IsDefaultAttribute()

判斷此屬性是否為預設值。

Match(Object)

在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

明確介面實作

名稱 Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取 物件的型別資訊,可用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱