RIA Development Center
FeaturesTipsEventsVideosSilverlight GallerySilverlight Hosting Resources
Brad Abrams gives a brief overview of what Microsoft .NET RIA Services is and how it's going to make your life simpler. Read more
See more tips
Which platform do you use most often?
(Check one)
AIR
AJAX
Flash
JavaFX
Silverlight
Other

View Results
Get regular email alerts when we publish new features!
DevX RIA Development Update

More Newsletters
Silverlight Tools for Visual Studio (cont'd)

Web Silverlight-enabled WCF Service Reference Support
A Silverlight application which needs to consume a WCF Service (or an .asmx service) requires a client side proxy through which to communicate with that service. Although this proxy is very complex and quite a task to write by hand, Visual Studio has access to a code generation library which can create this proxy for you. However, the code generation library which works for clients other than Silverlight will not work for Silverlight because the latter is limited to only a subset of the .NET Framework. To solve this problem, Silverlight Tools installs a separate code generation library (Microsoft.Silverlight.ServiceReference.dll) which will emit a Silverlight-compliant WCF Service client.

The list of components in Silverlight Tools probably should have referred to including "Service Reference Support" instead of "Web Reference Support" since the Add Web Reference option is not shown as available to Silverlight Applications as can be seen in the following screenshot.

Figure 19. Note that Add Reference and Add Service Reference are present but Add Web Reference is not.

The absence of the Add Web Reference option occasionally confuses developers until they are advised to simply choose the Add Service Reference option instead, as this excellent summary illustrates how to call a Web Service from a Silverlight application.

Team Build and Command Line Support
Visual Studio's Team Foundation Build is designed to provide a coordinated build process for major software projects. Team Foundation Build is capable of building code modules written in any language supported by Visual Studio and of any project type supported by Visual Studio. Silverlight Tools makes the necessary changes to Visual Studio so that Silverlight projects can be included in the Team Foundation Build process.

Silverlight developers can also use MSBuild to automate build tasks, as for example the creation of .xap packages. Dave Miles has prepared a good tutorial explaining how to use MSBuild with Silverlight content.

While most developers compile their applications (locally) by pressing either F5 or Ctrl-Shift-B, the .NET SDK includes a command line compiler, csc.exe. Silverlight Tools makes the necessary changes so that the command line compiler can also create a Silverlight .xap file.

Integration with Expression Blend
Many experienced Silverlight developers have discovered that the simultaneous use of both Visual Studio and Expression Blend is essential to an efficient development process. As previously described, Visual Studio has IntelliSense for XAML and of course is necessary for writing all event handlers. Expression Blend, on the other hand, includes an interactive design surface and is mandatory for creating most complex animations.

Fortunately, both tools use an identical project structure and are capable of opening either .sln or .proj files. Silverlight Tools adds an extra entry to the right click context menu for .xaml files in the Visual Studio Solution Explorer which offers the option to "Open in Expression Blend". This menu entry will only be displayed if Visual Studio is able to detect the presence of Expression Blend.


Figure 20.
 
Figure 21.

Silverlight Tools also adds a corresponding entry in the Expression Blend right click context menu which makes switching in the opposite direction equally easy.

Silverlight Developer Runtime
Installing the Silverlight Tools also results in the installation of the Silverlight Developer Runtime and the Silverlight 2 SDK.

There are both Mac and Windows versions of the Silverlight Developer Runtime. Both provide additional debug and error information. In both cases, the Developer Runtime must be installed on a client machine in order to do remote debugging. See the previously mentioned Peter Laudati blog article for an explanation of how to do this on a Mac.

Silverlight 2 SDK
The Silverlight 2 SDK contains a number of key support elements for building Silverlight applications: documentation, libraries, development tools and links to online samples.

Figure 22. Directory structure for the Silverlight 2 SDK.

Documentation for Silverlight takes two forms: documentation which can be incorporated into the Visual Studio built-in help files and stand alone documentation (Silverlight.chm). Obviously there is a significant advantage for Silverlight help to be available on an immediate basis simply by pressing the F1 key with the item in question selected. Unfortunately, while in most cases this integrated help will be successfully incorporated into the existing Visual Studio help files when the Silverlight Tools package is installed, this will not always occur due to different release/beta and install/uninstall combinations or because of localization mismatches. You can determine if you've achieved this integration by opening the Collection Manager in Visual Studio's built-in help. If the Microsoft Silverlight 2 SDK Documentation entry is checked, integrated Silverlight help should be available. If it is not, check it and click on the Update VSCC button.

Figure 23. View of the Visual Studio Collection Manager.

Silverlight help is also available in the standalone .chm file found in the SDK - Documentation - Help folder or as a separate download, independent of the SDK. This help is particularly useful for any designer or developer working exclusively in Expression Blend since there is currently no Silverlight help directly accessible from Expression Blend. Also, since Visual Studio does not currently permit filtering the integrated help files to include only Silverlight relevant content, you can achieve this result only by using the standalone help file.

The SDK also contains a "Breaking Changes" document which explains what changes in the RTW version of Silverlight 2 will cause Beta 2 Silverlight applications to no longer work.

The libraries included with the Silverlight SDK are divided into Client libraries and Server libraries. The Server libraries include two ASP.NET controls for Silverlight, asp:Silverlight and asp:MediaPlayer. Both are designed to allow developers to use the ASP.NET server control model to host Silverlight content. The media player control is designed to incorporate audio (WMA) and/or video (WMV) into a Silverlight application. The generic Silverlight Server Control is designed to host any generic XAML content. When a developer chooses to use an ASP.NET Web Application, the included .aspx page uses the asp:Silverlight control to host the XAML content provided by the Silverlight Application (See Figure 2).

The Client libraries installed by the SDK are shown in the following screenshot:

Figure 24. Directory listing of Silverlight Client libraries included in the Silverlight 2 SDK.

Notable assemblies in this list include System.Windows.Controls which contains the supplemental controls that are not included in the core Silverlight assemblies used by the browser plugin. These controls are the Calendar, DatePicker, GridSplitter and TabControl as shown in the following screenshot. Another key assembly is System.Windows.Controls.Data which contains the new Microsoft DataGrid.

Figure 25. Red Gate's .NET Reflector gives this useful view of the contents of the System.Windows.Controls assembly.

Other key assemblies include System.Xml.Linq which contains the LINQ to XML libraries and System.Xml.Serialization which contains the XML serialization libraries.

The principal development tool included in the Silverlight 2 SDK is the code generation library (Microsoft.Silverlight.ServiceReference.dll) which is use to create Silverlight compliant WCF Service client proxies.

Summary
The Silverlight Tools package contains a diverse collection of documentation, libraries and tools essential for Silverlight development using Visual Studio. The latest release represents another major milestone achieved on the path to widespread Silverlight market penetration.

Links

  • Getting Started with Silverlight

  • What's New with Silverlight Tools Beta 2 (Visual Web Developer Team Blog)

  • Silverlight Tools Must Be Updated After Installing Visual Studio 2008 SP1 (Blog article by Amy Dullard)

  • How to Create a New Silverlight Project (MSDN Help File)

  • How to Build a Service for Silverlight Clients (MSDN Help File)

  • Debugging Services for Silverlight Applications (MSDN Help File)

  • ASP.NET Controls for Silverlight (MSDN Help File)

  • Silverlight Tools Installation Speed Bumps (Blog article by one of the Silverlight Tools team members)

    * This article was commissioned by and prepared for Microsoft Corporation. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


  • Previous Page: IntelliSense and Code Generators for XAML  
    Cal Schrotenboer is a C# developer with experience in building Windows Forms application front ends for SQL Server databases. He also teaches programming classes at Foothill College in Los Altos Hills, California and Microsoft Network Administration (MCSE) classes at Mission College in Santa Clara. Cal maintains a WPF blog at www.WPFLearningExperience.com. His outside interests include travel and photography (www.travelswithcal.com).
    Page 1: Project TemplatesPage 3: Web Silverlight-enabled WCF Service Reference Support
    Page 2: IntelliSense and Code Generators for XAML 
    Rate This Content:
    Low     High
    5 after 4 ratings