DynamicApplication Class

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Represents an application object for dynamic language applications, and provides the entry point for the application.

Namespace:  Microsoft.Scripting.Silverlight
Assembly:  Microsoft.Scripting.Silverlight (in Microsoft.Scripting.Silverlight.dll)

public class DynamicApplication : Application

The DynamicApplication class contains the entry point for dynamic language applications. It starts the dynamic language runtime, and provides the application with access to the root interface object.

To obtain the DynamicApplication object for your application, use the DynamicApplication.Current property.


You can also use the static Application.Current property, but only if your code is executing on the user interface thread.

To load the root interface object for your application, use the LoadRootVisual method.

The following example shows simple startup code for IronPython, IronRuby, and Managed JScript. In each case, the example defines an App class with a start method, creates an instance of the class, and calls the start method.

The example uses an app.xaml file, which is the same for all languages. The file is listed following the code.

On initialization, the example uses the Application.Current property to get the DynamicApplication object, and then uses the LoadRootVisual method to load a UserControl from the app.xaml file, which is located in the same folder as the entry point code. In the start method, the example sets the text of a TextBlock control named Message.

For information on running dynamic language code using Chiron.exe, see Dynamic Languages in Silverlight 2.

# ---- IronPython ----
from System.Windows import Application
from System.Windows.Controls import UserControl

class App:
    def __init__(self):
        self.scene = Application.Current.LoadRootVisual(UserControl(), "app.xaml")

    def start(self):
        # TODO: Replace this with your application start logic.
        self.scene.Message.Text = "Welcome to Silverlight and IronPython."


# ---- IronRuby ----
include System::Windows
include System::Windows::Controls

class App

  def initialize
    @scene = Application.Current.LoadRootVisual(UserControl.new(), "app.xaml")

  def start
    # TODO: Replace this with your application start logic.
    @scene.find_name('Message').text = "Welcome to Silverlight and IronRuby."


// ---- Managed JScript ----

function App() {
    this.scene = Application.Current.LoadRootVisual(new UserControl(), "app.xaml")

App.prototype.start = function() {
    // TODO: Put application logic here.
    this.scene.Message.Text = "Welcome to Silverlight and Managed JScript."

app = new App

The app.xaml file contains the following XAML:

    x:Name="Message" TextWrapping="Wrap" Foreground="Black" >


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