다음을 통해 공유


NSInstance.Error Event

Occurs when a fatal error is raised by a Notification Services engine component.

네임스페이스: Microsoft.SqlServer.NotificationServices
어셈블리: Microsoft.SqlServer.NotificationServices (in 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는 이벤트의 사용을 지원하지만 새로 선언하는 것은 지원하지 않습니다.

The following examples show how to use the Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler delegate to handle events:

' 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);
    }

주의

When you host the Notification Services engine, the hosting process can provide an Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler delegate for this event. If the Notification Services engine encounters a non-recoverable error and needs to terminate, it logs the error and calls the Microsoft.SqlServer.NotificationServices.NSInstance.ErrorEventHandler delegate so the hosting process is made aware of the error condition.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

NSInstance Class
NSInstance Members
Microsoft.SqlServer.NotificationServices Namespace