Share via


ParserErrorEventArgs Object

Provides data for XAML parser error events.

XAML
Cannot be used in XAML.
Scripting
Obtained as arguments for certain event handlers.

Properties

CharPosition ErrorCode, ErrorMessage, ErrorType, LineNumber, Name, XamlFile, XmlAttribute, XmlElement

Methods

Equals, FindName, GetHost, GetValue, SetValue

Remarks

Parser errors are the result of initial XAML source parsing. Parser errors might result for cases where the XAML is not well formed XML, or for specific Silverlight object model violations. For instance, 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 1.0.

Examples

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

JavaScript
    // errorArgs is an instance of ParserErrorEventArgs
    if(errorArgs.ErrorType == "ParserError")
    {
      var parserErrorMsg = "Silverlight Parser Error  \n\n";
               
      // Basic error event informaiton.
      parserErrorMsg += "Error Type:    " + errorArgs.errorType     + "\n";
      parserErrorMsg += "Error Message: " + errorArgs.errorMessage  + "\n";
      parserErrorMsg += "Error Code:    " + errorArgs.errorCode  + "\n";
            
      //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);
    } 

See Also

Silverlight Application Scripting Error Handling
ErrorEventArgs
RuntimeErrorEventArgs