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.
Note: |
---|
Silverlight for Windows Phone does not support the HTML Bridge feature. |
In This Section
Returning or Passing Managed Types to JavaScript
Describes how you can use managed types as parameters in JavaScript function calls.Passing JavaScript Objects to Managed Code
Describes how JavaScript types are converted to managed code in Silverlight.Constructing Managed Types from JavaScript
Explains how you can obtain wrappers around managed types in Silverlight.