InstallException 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 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
是当前异常原因的异常。 如果未 innerExceptionnull 参数,则会在处理内部异常的 catch 块中引发当前异常。