Compartir a través de


ParserErrorEventArgs

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

Provides data for XAML parser error events.

Syntax Notes

ParserErrorEventArgs is obtained as input for your own event handlers.

Managed Equivalent

None

Remarks

Parser errors are the result of initial XAML source parsing. Parser errors might result from cases in which the XAML is not well-formed XML, or for specific Silverlight object-model violations. For example, you would get a parser error if you attempted to specify a child element for an element that did not support a child collection.

The XmlAttribute and XmlElement properties are not implemented in Silverlight.

Example

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

// errorArgs is an instance of ParserErrorEventArgs.
    if(errorArgs.ErrorType == "ParserError")
    {
      var parserErrorMsg = "Silverlight Parser Error  \n\n";
               
      // Provide basic error event information.
      parserErrorMsg += "Error Type:    " + errorArgs.errorType     + "\n";
      parserErrorMsg += "Error Message: " + errorArgs.errorMessage  + "\n";
      parserErrorMsg += "Error Code:    " + errorArgs.errorCode  + "\n";
            
      //Provide parser-specific error event information.
      parserErrorMsg += "XamlFile:      " + errorArgs.xamlFile      + "\n";
      parserErrorMsg += "XmlElement:    " + errorArgs.xmlElement    + "\n";
      parserErrorMsg += "XmlAttribute:  " + errorArgs.xmlAttribute  + "\n";
      parserErrorMsg += "Line:          " + errorArgs.lineNumber    + "\n";
      parserErrorMsg += "Position:      " + errorArgs.charPosition  + "\n";
            
      // Display the error message.
      alert(parserErrorMsg);
    }