RunInstallerAttribute 類別

定義

指定在安裝組件時是否應該叫用 Visual Studio Custom Action Installer 或 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會在安裝元件時叫用。 標記為 RunInstallerAttribute 設為 false 的成員將不會叫用安裝程式。 預設為 true

注意

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

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

建構函式

RunInstallerAttribute(Boolean)

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

欄位

Default

設定預設可見度,即 No。 這個 static 欄位是唯讀的。

No

指定在安裝組件時不要叫用 Visual Studio Custom Action Installer 或 Installutil.exe (安裝程式工具)。 這個 static 欄位是唯讀的。

Yes

指定在安裝組件時應該要叫用 Visual Studio Custom Action Installer 或 Installutil.exe (安裝程式工具)。 這個 static 欄位是唯讀的。

屬性

RunInstaller

取得值,指出在安裝組件時是否要叫用安裝程式。

TypeId

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

(繼承來源 Attribute)

方法

Equals(Object)

判斷指定之 RunInstallerAttribute 的值是否與目前的 RunInstallerAttribute 相等。

GetHashCode()

產生目前 RunInstallerAttribute 的雜湊程式碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

判斷這個屬性是否為預設值。

Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

明確介面實作

_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)

適用於

另請參閱