Share via

ScriptableTypeAttribute Class

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

Indicates that all public properties, methods, and events on a managed type are available to JavaScript code when they are registered by using the RegisterCreateableType method.

Inheritance Hierarchy


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


<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct, AllowMultiple := False,  _
    Inherited := False)> _
Public NotInheritable Class ScriptableTypeAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple = false, 
    Inherited = false)]
public sealed class ScriptableTypeAttribute : Attribute

The ScriptableTypeAttribute type exposes the following members.


  Name Description
Public method ScriptableTypeAttribute Initializes a new instance of the ScriptableTypeAttribute class.



  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)



The ScriptableTypeAttribute method exposes all properties, methods, and events as scriptable endpoints.

If you want to expose only a subset of properties, methods, and events as scriptable endpoints, do not use a ScriptableTypeAttribute object. Instead, attribute the subset of properties, methods, and events with a ScriptableMemberAttribute object.

The ScriptableMemberAttribute setting overrides the default behavior inherited from ScriptableTypeAttribute.

If a type is attributed with ScriptableTypeAttribute, by default, all members that are used as input parameters or return values can be created by using the createManagedType and createManagedArray helpers.


You can turn off support for obtaining script wrappers for input parameters and return values that are exposed on a scriptable property, method, or event by explicitly attributing individual members with the code ScriptableMember(EnableCreateableTypes := false). The following example shows how to disable a single method and let all other methods remain scriptable.

public class SMT_ScriptableManagedType
    [ScriptableMember(EnableCreateableTypes = false)] // No access
     public string GetString1()
        { return "abcdefg"; }

     public string GetString2()            // Can be accessed.
        { return "123456"; }

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.