InstallException 建構函式

定義

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

多載

InstallException()

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

InstallException(String)

初始化 InstallException 類別的新執行個體,並且指定對使用者顯示的訊息。

InstallException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 InstallException 類別的新執行個體。

InstallException(String, Exception)

初始化 InstallException 類別的新執行個體,指定對使用者顯示的訊息以及造成這個例外狀況的內部例外狀況參考。

InstallException()

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

public:
 InstallException();
public InstallException ();
Public Sub New ()

範例

下列範例示範建 InstallException 構函式。 它是類別範例的 InstallException 一部分。

在此範例中,Installutil.exe 呼叫 Commit 方法。 中的 Commit 程式代碼假設名為 FileDoesNotExist.txt 的檔案存在,才能認可元件的安裝。 如果檔案 FileDoesNotExist.txt 不存在, Commit 則引發 InstallException

注意

這個範例示範如何使用其中一個多載版本的 InstallException 建構函式。 如需其他可能可用的範例,請參閱個別多載主題。

virtual void Commit( IDictionary^ savedState ) override
{
   Installer::Commit( savedState );
   Console::WriteLine( "Commit ..." );
   
   // Throw an error if a particular file doesn't exist.
   if (  !File::Exists( "FileDoesNotExist.txt" ) )
         throw gcnew InstallException;

   
   // Perform the final installation if the file exists.
}
public override void Commit(IDictionary savedState)
{
   base.Commit(savedState);
   Console.WriteLine("Commit ...");
   // Throw an error if a particular file doesn't exist.
   if(!File.Exists("FileDoesNotExist.txt"))
      throw new InstallException();
   // Perform the final installation if the file exists.
}
Public Overrides Sub Commit(savedState As IDictionary)
   MyBase.Commit(savedState)
   Console.WriteLine("Commit ...")
   ' Throw an error if a particular file doesn't exist.
   If Not File.Exists("FileDoesNotExist.txt") Then
      Throw New InstallException()
   End If
   ' Perform the final installation if the file exists.
End Sub

適用於

InstallException(String)

初始化 InstallException 類別的新執行個體,並且指定對使用者顯示的訊息。

public:
 InstallException(System::String ^ message);
public InstallException (string message);
new System.Configuration.Install.InstallException : string -> System.Configuration.Install.InstallException
Public Sub New (message As String)

參數

message
String

要顯示給使用者的訊息。

範例

下列範例示範建 InstallException 構函式。 它是類別範例的 InstallException 一部分。

在此範例中,Installutil.exe 呼叫 Uninstall 方法。 只有在名為 FileDoesNotExist.txt 的檔案存在時,才會進行卸載。 否則會 InstallException引發 。

注意

這個範例示範如何使用其中一個多載版本的 InstallException 建構函式。 如需其他可能可用的範例,請參閱個別多載主題。

virtual void Uninstall( IDictionary^ savedState ) override
{
   Installer::Uninstall( savedState );
   Console::WriteLine( "UnInstall ..." );
   
   // Throw an error if a particular file doesn't exist.
   if (  !File::Exists( "FileDoesNotExist.txt" ) )
         throw gcnew InstallException( "The file 'FileDoesNotExist'  does not exist" );

   
   // Perform the uninstall activites if the file exists.
}
public override void Uninstall(IDictionary savedState)
{
   base.Uninstall(savedState);
   Console.WriteLine("UnInstall ...");
   // Throw an error if a particular file doesn't exist.
   if(!File.Exists("FileDoesNotExist.txt"))
      throw new InstallException("The file 'FileDoesNotExist'" +
         " does not exist");
   // Perform the uninstall activites if the file exists.
}
Public Overrides Sub Uninstall(savedState As IDictionary)
   MyBase.Uninstall(savedState)
   Console.WriteLine("UnInstall ...")
   ' Throw an error if a particular file doesn't exist.
   If Not File.Exists("FileDoesNotExist.txt") Then
      Throw New InstallException("The file 'FileDoesNotExist'" + " does not exist")
   End If
   ' Perform the uninstall activites if the file exists.
End Sub

適用於

InstallException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 InstallException 類別的新執行個體。

protected:
 InstallException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected InstallException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Configuration.Install.InstallException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Configuration.Install.InstallException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

SerializationInfo,包含所擲回之例外狀況的相關序列化物件資料。

context
StreamingContext

包含有關來源或目的端內容資訊的 StreamingContext

適用於

InstallException(String, Exception)

初始化 InstallException 類別的新執行個體,指定對使用者顯示的訊息以及造成這個例外狀況的內部例外狀況參考。

public:
 InstallException(System::String ^ message, Exception ^ innerException);
public InstallException (string message, Exception innerException);
new System.Configuration.Install.InstallException : string * Exception -> System.Configuration.Install.InstallException
Public Sub New (message As String, innerException As Exception)

參數

message
String

要顯示給使用者的訊息。

innerException
Exception

做為目前例外狀況發生原因的例外狀況。 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。

適用於