Unable to Connect to Silverlight Application

PROBLEM

You cannot record your Silverlight application through Test Studio and receive an "Unable to connect" error message.

KNOWN ISSUES

  • The MIME Type for your XAP file is not properly registered on your web server. This is the most common cause for this type of issue.
  • Automation only supports .XAP Silverlight app deployment (the .NET method).

     

    NOTE: .XBAP or Javascript Silverlight deployment is not supported.

SOLUTION

  1. Make sure that you have registered the .XAP file extension within IIS. These instructions are also documented at http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/.
    1. Click Start > Run (XP) or Start then click in the search field (Vista/Win7).
    2. Type IIS within the search/run field.
    3. Hit 'Enter' on your keyboard.
    4. Make sure you are targeting the "Default Web Site" in the left column.
    5. Double-click MIME Types in Features View.
    6. Click Add (right column).
    7. Set the file extension to .XAP.
    8. Set the MIME Type to application/x-silverlight-app
    9. Click OK.
  2. If the Web and Silverlight app is deployed locally, try adding a period ('.') after localhost, as in http://localhost.:
  3. Delete the entire cache for the test playback browser:
    1. In Interent Explorer, select: Tools > Internet Options > General Tab > Delete (Within the browsing history section)
    2. In Firefox, select: Tools > Clear Recent History > Select Everything in the 'Time Range to Clear' drop-down menu > Choose Clear Now
    3. In Safari, select: Settings (the gear in the upper-right of the Safari window) > Reset Safari > Check only Empty the Cache > Click Reset
    4. In Chrome, select: Tools menu > Options > Click the Under the Hood tab > Click Clear browsing data...
  4. Reset Internet Explorer settings.
  5. Try increasing the (Settings.) Silverlight Connect Timeout if the Silverlight app has a longer load time.
  6. Try setting externalAccessfromCrossDomainCallers to script only your application's AppManifest.xaml file by doing the following in your html page and Silverlight manifest:
    1. Example for html page:
       

      <div id="silverlightControlHost" />

      <object height="300" width="300" type="application/x-silverlight-2" data="data:application/x-silverlight-2," >

      <param value="http://a-remote-domain.com/ClientBin/SilverlightClient.xap" name="source" />

      <param value="white" name="background" />

      <param value="3.0.40723.0" name="minRuntimeVersion" />

      <param value="true" name="enableHtmlAccess" />

      <param value="visOnly=true" name="initParams" />

      <a style="text-decoration: none;" href="http://go.microsoft.com/fwlink/?LinkID=149156">

      <img style="border-style: none; width: 400px; height: 200px;" alt="Install Microsoft Silverlight" src="http://storage.timheuer.com/sl4wp-ph.png"/></a></object>

      <iframe style="border: 0px none ; visibility: hidden; height: 0pt; width: 0pt;" /></div>

       

    2. Example for SL Manifest:

      <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      ExternalCallersFromCrossDomain="ScriptableOnly">

       <Deployment.Parts>

       </Deployment.Parts>

       </Deployment>


      (see this Microsoft forum thread for more information: http://forums.silverlight.net/forums/p/101955/340407.aspx)

  7. Try setting the "windowless" property for your Silverlight app to "true":

    Example (similar to first example above):

    <object id="xamlHost0" width="900" height="412" type="application/x-silverlight">

        <param value="transparent" name="background"/>

        <param value="true" name="windowless"/>

        <!-- a bunch of other params go here -->

    </object>

  8. Check the headers your server is sending for the Silverlight Page by:
    1. Install/Run Fiddler and load your Silverlight page.
    2. Click the response for the .xap file
    3. Click Inspectors > Headers.

    There should be an entry titled: Content:application/x-silverlight-app
    This must be in response in order for the Telerik Testing Framework or Test Studio to detect the Silverlight app.