語言

InstallException 建構函式

定義

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

多載

名稱 Description
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。

Note

這個範例展示了如何使用其中一個超載版本 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。

Note

這個範例展示了如何使用其中一個超載版本 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

the that 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 當前例外。

適用於