Share via


NSInstance.Error Event

Notification Services エンジン コンポーネントによって致命的なエラーが発生した場合に起こります。

名前空間: Microsoft.SqlServer.NotificationServices
アセンブリ: Microsoft.SqlServer.NotificationServices (microsoft.sqlserver.notificationservices.dll 内)

構文

'宣言
Public Event Error As ErrorEventHandler
public event ErrorEventHandler Error
public:
event ErrorEventHandler^ Error {
    void add (ErrorEventHandler^ value);
    void remove (ErrorEventHandler^ value);
}
/** @event */
public void add_Error (ErrorEventHandler value)

/** @event */
public void remove_Error (ErrorEventHandler value)
JScript はイベントの使用をサポートしていますが、新規の宣言はサポートしていません。

使用例

Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler デリゲートを使用してイベントを処理する例を次に示します。

' Define an error handler for the hosted execution engine.
Private Sub MyErrorHandler(ByVal sender As Object, _
    ByVal e As ErrorEventArgs) Handles instance.Error
    Console.WriteLine(e.GetException().ToString())
End Sub

' Start the instance, using the error handler to
' handle any exceptions thrown by the running instance.
Public Sub StartInstance(ByVal myInstance As NSInstance)
    Try
        'Start the instance.
        myInstance.StartInstance()

        ' Verify that the hosted engine is running.
        If myInstance.IsRunning = True Then
            Console.WriteLine("The instance is running.")
        Else
            Console.WriteLine("The instance is NOT running!")
        End If

    Catch ex As Exception
        Console.WriteLine(ex.Message)
    End Try
// Define an error handler for the hosted execution engine.
private void MyErrorHandler(object sender, ErrorEventArgs e)
{
    Console.WriteLine(e.GetException().ToString());
}

// Start the instance, using the error handler to
// handle any exceptions thrown by the running instance.
public void StartInstance(NSInstance myInstance)
{
    try
    {
        // Add an error handler to the instance.
        myInstance.Error +=
            new NSInstance.ErrorEventHandler(MyErrorHandler);

        //Start the instance.
        myInstance.StartInstance();

        // Check the IsRunning property to verify that 
        // this process is running the instance.
        if (myInstance.IsRunning == true)
            Console.WriteLine("The instance is running.");
        else
            Console.WriteLine("The instance is NOT running!");

    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

解説

Notification Services エンジンをホストする場合、ホスト側のプロセスはこのイベントの Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler デリゲートを提供できます。Notification Services エンジンが回復不能なエラーを検出し、終了する必要が生じると、そのエラーが記録され、Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler デリゲートが呼び出されます。これにより、ホスト側のプロセスはエラー状態が生じたことを認識できます。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

NSInstance Class
NSInstance Members
Microsoft.SqlServer.NotificationServices Namespace