Sdílet prostřednictvím


Silverlight and JavaScript Marshaling

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

The following general rules control Silverlight and JavaScript marshaling behavior:

  • Managed types are returned or passed by reference to JavaScript.

  • JavaScript types must be converted to a corresponding managed wrapper, which is then passed to managed code.

  • If an error occurs when trying to marshal managed data to JavaScript, an InvalidOperationException is thrown. There is no straightforward way to consistently trap different error types in the native invocation layer and map them back to ArgumentException or other exception types.

  • If an error occurs when trying to marshal JavaScript data to managed code, an exception is returned to the JavaScript caller. The exception text describes the error.

NoteNote:

Silverlight for Windows Phone Silverlight for Windows Phone does not support the HTML Bridge feature.

In This Section