Freigeben über


RuntimeErrorEventArgs

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Provides data for runtime error events.

Syntax Notes

RuntimeErrorEventArgs is obtained as input for your own event handlers.

Managed Equivalent

None

Remarks

By specifying error handlers as part of initial Silverlight plug-in instantiation code, you can introduce custom error handling even for runtime errors, including suppressing error dialog boxes.

Example

The following JavaScript example shows the portion of an event handler that displays error information specific to runtime errors.

// errorArgs is an instance of RuntimeErrorEventArgs.
    if(errorArgs.ErrorType == "RuntimeError")
    {
      var runtimeErrorMsg = "Silverlight Runtime Error  \n\n";
            
      // Provide basic error event information.
      runtimeErrorMsg += "Error Type:    " + errorArgs.errorType     + "\n";
      runtimeErrorMsg += "Error Message: " + errorArgs.errorMessage  + "\n";
      runtimeErrorMsg += "Error Code:    " + errorArgs.errorCode  + "\n";
            
      // Provide runtime-specific error event information.
      if (errorArgs.lineNumber != 0)
      {
        runtimeErrorMsg += "Line:     " + errorArgs.lineNumber     + "\n";
        runtimeErrorMsg += "Position: " +  errorArgs.charPosition  + "\n";
      }
     
     runtimeErrorMsg += "MethodName: " + errorArgs.methodName     + "\n";
            
     alert(runtimeErrorMsg);
    }