Compartilhar via


OnError (Silverlight Plug-in Object)

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

Specifies the name of the handler to call when the Silverlight plug-in generates a XAML parse error or run-time error at the native-code level.

Syntax

object Element

<object ...>
  <param name="onerror" value="functionname"/>
  ...
</object>

Silverlight.js

Silverlight.createObject(,,,{},{onError:handlername}};
-or-
Silverlight.CreateObjectEx({events:{onError:handlername});

JavaScript

You cannot assign the handler at run time. You can get the value, but the value is just the function name.

COM

IXcpControl::OnError

Managed Code

Managed code has the first chance to catch errors from user code as exceptions so long as they are recoverable. For more information, see Error Handling.

Property Value

The name of the function that is invoked when the Silverlight plug-in generates a parse or run-time error at the native-code level. The default value is null.

Remarks

If you use the Silverlight.js client library, the Silverlight.js functions might define a default error handler and then reference it in the default behavior for CreateObject and CreateObjectEx. In that case, the default value of null might not apply. For more information, see Silverlight.js Reference.

Errors might be generated in the Silverlight run-time components in the following situations:

Other handlers are available for asynchronous events that are associated with particular objects or actions in the JavaScript API; these are generally recoverable errors for the application. (In contrast, most cases that invoke OnError are not recoverable or at least leave Silverlight content in an incomplete state.) For example, you can handle the DownloadFailed event of the Downloader class. These events are not processed by an OnError handler.

Arguments for an OnError Function

sender

object

The Silverlight plug-in that invoked the event.

errorEventArgs

object

The error and its source location. For more information, see ErrorEventArgs.