Partager via


HtmlWindow.CreateInstance Method

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

Creates an instance of the specified JavaScript type.

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

Syntax

'Declaration
Public Function CreateInstance ( _
    typeName As String, _
    ParamArray args As Object() _
) As ScriptObject
public ScriptObject CreateInstance(
    string typeName,
    params Object[] args
)

Parameters

Return Value

Type: System.Windows.Browser.ScriptObject
A JavaScript type.

Exceptions

Exception Condition
ArgumentNullException

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

ArgumentException

typeName is an empty string or cannot be resolved.

-or-

There is a type mismatch between one of the supplied creation parameters and the target parameter(s).

Remarks

The input parameters follow the rules for passing managed types to JavaScript.

The constructed instance is returned by using the heuristics described in Passing JavaScript Objects to Managed Code.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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