Like what you see? Check out other labs at the MIX Online Lab »

Questions & Known Issues

We recommend you read through this list before you start using Gestalt. There are some known issues with this release, while there are others with how browsers handle different scenarios. Some of these answers may say you a few hours of hair-pulling debugging.

Known Issues

  1. Locally run copies of a Gestalt application won't run.

    When a Gestalt application is run locally the Gestalt application will not instantiated. This is "by design"; the browser sandbox doesn't allow files that need to be served off a web server to be read off the local disk. The solution is to place your files on a web server and request the pages from there

  2. Why Don’t Relative Media and Image Paths Work in XAML?

    If you use relative image and media paths in your XAML (as in the example above), the images will be loaded relative to the location of the Gestalt XAP, and not relative to the page (unless the page and XAP are in the same folder). There are three ways to resolve this:

    1. Use absolute paths.
    2. Use relative paths that are relative to the Gestalt XAP (see gestaltpath in gestalt.js).
    3. Move the Gestalt files to the same folder as your page.


  1. Why does my Ruby work and equivalent Python code fail?

    Indentation is significant in Python. Most likely your script is indented over within that page and that has the effect of changing the very meaning of your Python code. We highly recommend that when you’re writing a Python script, let it start at the first column and indent as necessary there on out. Problems are typically caused when you copy/paste Python code into the page.

  2. Why is XAML inside a Script Tag?

    This has been changed from XML tag in Gestalt 0.6 to the Script tag in Gestalt 1.0. This has the follwoing two advantages:

    1. There are no breakages in any of the browsers
    2. Gestalt application's can be run in isolated scopes the "id" of the XAML script is the same as the "class" of the Ruby or Python script tag.
  3. How Do I Import Namespaces in Ruby and Python?

    If you want to import (for example) the System.Diagnostics namespace, the syntax in IronRuby is:

    include System::Diagnostics

    and the syntax in IronPython is:

    from System.Diagnostics import *

    By default, the following namespaces are available to your IronRuby code:

    include System::Windows::Controls
    include System::Windows::Browser
    include System::Windows::Media
    include System::Windows
    include System::Json

    And the following namespaces are imported by default for IronPython:

    from System.Windows.Controls import * 
    from System.Windows.Browser import *
    from System.Windows.Media import *
    from System.Windows import *
    from System import EventHandler

  4. How Can I Scope a Script to Run Only for One XAML Block?

    By default, each script applies to every XAML block on your page. If you want to constrain a certain script block to be visible to only one XAML block, you can scope it by setting the class attribute on the script tag. For example, if you have a XAML block with id="blinking_mushroom", you can scope a python or ruby script like this:

    <script type="text/python" class="blinking_mushroom">

  5. How Many Copies of Gestalt Get Loaded?

    If you have zero or one XAML blocks on your page, Gestalt will be instantiated only once, no matter how many script blocks you have on the page. This means that, if you are using Gestalt purely for DOM manipulation with Ruby or Python, you will have only one instance of Gestalt loaded, sharing global state, exactly as you would expect with JavaScript, regardless of how many script blocks you have.

    If you have more than one distinct XAML block, Gestalt is instantiated exactly once per XAML block (again, regardless of the number of script blocks). This is because the XAML blocks are loaded in Silverlight, which does not support multiple blocks per Silverlight instance. Therefore, you probably don’t want to use more than 5 or 10 distinct XAML blocks on a page, just as you wouldn't want to use that many distinct Silverlight controls.

    Of course, Gestalt is only downloaded once, regardless of how many XAML block are on the page

  6. How Can I Debug Ruby or Python in Visual Studio?

    Heres how you can do this for Ruby or Python:

    1. set: DLR.settings = { debug:true };
    2. define the .rb or .py file as external file like so: <script class=”media” src=”” type=”text/python”></script> or <script class=”media” src=”audio.rb” type=”text/python”></script>
    3. Then attach the VS debugger to the instance of IE, FF or Chrome that you are running your app in
    4. Set a breakpoint in your .py or .rb file
    5. Refresh the browser
    6. You will see the debugger break on your breakpoint! Step through with F11
  7. How do I go about debugging a Gestalt application?

    Another convenient way to debug exceptions that are raised while you are developing your application is to add the System.Diagnostics namespace to your Python or Ruby code. In Python the syntax is:

    from System.Diagnostic import *

    In Ruby the syntax is:

    include System::Diagnostic

    Then inline the following in your Python functions or classes. You can make a call to the Debug.Writeline() method which takes a string as a parameter:

    Debug.WriteLine("hello debug window")


    Debug.WriteLine( classInstance.aProperty.ToString() ) 
    # this will cast whatever object type the aProperty is to a string

    In Ruby, it's called similarly:

    Debug.WriteLine "hello debug window"


    Debug.WriteLine classInstance.aProperty.ToString()

    It is also useful to know about the try/except statement in Python. Use it in this form inline in code. This writes the error message associated with the failed line of code to a debug window. DebugView is one tool that allows you to view debug messages.

    import sys
       some code that might fail

    In Ruby do the following:

       some code that might fail
    rescue => e
       Debug.WriteLine e.message

    You may find that background threads tend to swallow exceptions, such as a Storyboard_Completed event. You can add a Python try/except or a Ruby begin/rescue to any code in these and it will surface any errors that occur.

    Note that to see a debug message appear you must be running both the DebugView tool and have added as a trusted site. Alternately you can run the files locally. You can use any other debugger tool that accepts debug messages as well.

    Take a look at a Python debug sample and a Ruby debug sample and download the debug samples pack.