ScriptObject.Invoke Method

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

Invokes a method on the current scriptable object, and optionally passes in one or more method parameters.

Namespace:  System.Windows.Browser
Assembly:  System.Windows.Browser (in System.Windows.Browser.dll)


Public Overridable Function Invoke ( _
    name As String, _
    ParamArray args As Object() _
) As Object
public virtual Object Invoke(
    string name,
    params Object[] args


  • args
    Type: array<System.Object[]
    Parameters to be passed to the method.

Return Value

Type: System.Object
An object that represents the return value from the underlying JavaScript method.


Exception Condition

name is nulla null reference (Nothing in Visual Basic).


name is an empty string.


name contains an embedded null character (\0).


The method does not exist or is not scriptable.


The underlying method invocation results in an error. The .NET Framework attempts to return the error text that is associated with the error.


Return values follow the rules for returning types from JavaScript to managed code using by-reference marshaling rules. For more information, see Returning or Passing Managed Types to JavaScript.

The possible types for args follow the rules for passing managed types to JavaScript using by-reference marshaling rules.

If args is nulla null reference (Nothing in Visual Basic), it is interpreted as an empty parameter list. As a result, passing nulla null reference (Nothing in Visual Basic) is the same as passing new object[].

The actual type of the return value is always a string, a primitive type, or a ScriptObject reference. If the underlying value of the requested property is a managed type (other than a derivation of ScriptObject), you can use the ManagedObject property to get the underlying managed type reference.


The following example shows how you can access individual items in a ScriptObject that contains either a JavaScript collection or a dictionary by invoking the item property (ordinal for arrays, and key for dictionary) and passing an ordinal for a parameter.

// Fetch the sixth item in a collection.
// Fetch address item from dictionary.

However, this approach will not work for simple JavaScript arrays. For information about how to access an item in a simple JavaScript array, see ScriptObject.GetProperty.

Version Information


Supported in: 5, 4, 3


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.