Friday, August 21, 2009

Silverlight 3.0

Silverlight is another new technology from Microsoft Corporation for creating rich browser based applications. It can be easily used to deploy data driven rich applications on browser.

Silverlight can also be defined as a cross platform, cross browser plug-in for developing rich applications on browsers. It exposes a programming framework and features that are a subset of the .Net framework and Windows Presentation Framework (WPF).

The latest version from Microsoft of Silverlight is Silverlight 3.0. Silverlight enables development of the next generation of Microsoft .NET-based media experiences and rich interactive applications (RIAs) for the Web.

Need of Silverlight
ASP.NET AJAX was developed to improve performance in the browser by making post backs and calls between the browser and server asynchronously. ASP.NET AJAX uses new built-in types and controls and JavaScript.

Both ASP.NET and ASP.NET AJAX are heavily dependent upon the ASP.NET page event life cycle, are tightly coupled to the server, and have a tough time competing with advanced, media-rich plug-in solutions such as Adobe Flash. Additionally, it is difficult to create Web applications that offer a consistent experience across all supported browsers and platforms by using ASP.NET and AJAX. In 2006, Microsoft began developing a solution to extend into the browser and offer media experiences more robust than competing plug-in solutions. Silverlight is the result of that search.

Silverlight runs in the browser as a "sandbox" - a secure zone installed into the browser that accommodates Silverlight functionality while completely protecting the host platform from any possibly adverse actions performed by Silverlight

Silverlight Technology

Unlike ASP.NET, the bulk of Silverlight processing occurs on the client machine thus decreasing server resource utilization and improving the Web experience on the client.

When a client initially attempts to run a Silverlight application, if the Silverlight plug-in has not been installed on the client machine, it will be downloaded and installed. Upon subsequent requests to run the application, the application will instantiate on the client machine and make requests for resources from the server only when necessary.

The Silverlight plug-in can be thought of as a scaled-down version of the full .NET Framework. It only contains those classes and functionality that are applicable to a Silverlight Web client and those were streamlined and optimized for use on the Web client machine.

Silverlight was designed using the same design paradigm as ASP.NET. Each page of a Silverlight application includes an associated code behind file that includes the code that handles events fired by the page.

Silverlight resembles WPF in that it uses Extensible Application Markup Language (XAML) to construct the user interface (presentation layer). As Silverlight applications are composed of text-based files that include markup and code, they can be created using any text editor; however, more advanced tools and development environments such as Visual Studio or Expression Blend simplify the task significantly.

Silverlight Architecture

Version 1.0 of Silverlight used JavaScript and supported the industry-leading Windows Media Services enabling delivery of audio and video that includes 2D and vector graphics.
Version 2 includes all features of version 1.0 and:
• Support for the .NET Framework.
• Support for .NET-compliant programming languages such as C#, Visual Basic, Python, and Ruby.
• Support for database operations and language-integrated query (LINQ).

Silverlight Hosting

Microsoft Silverlight functionality is completely encapsulated within the Silverlight plug-in. Silverlight applications simply require a Web server to be equipped as they would be for hosting HTML documents. Silverlight applications can be hosted on any Web server accessible to the target audience. The two most commonly used Web servers are Microsoft Internet Information Server (IIS) and Apache.

Executing a Silverlight application on a Web client machine is a two step process.

First, the application will detect if the Silverlight plug-in is installed on the Web client machine. If the plug-in is not installed, the user will be prompted with an option to download the plug-in. If the user opts to do so, a request will be made of the Web server to download and install the plug-in. The Silverlight plug-in is embodied in a .dll executable file that is loaded into the Web client browser memory once installed. The only interaction required by the Web client when installing the Silverlight plug-in is to grant permission for the plug-in to be installed. Various Web servers, including Microsoft Internet Information Server (IIS), may require slight configuration modifications so that the Silverlight executable file will be downloaded to the Web client when requested.

Second, once the Silverlight plug-in is installed on the Web client machine, the Silverlight application itself must be downloaded. A Silverlight application may consist of many types of files. Slight configuration modifications may be necessary on the Web server, such as MIME types, so that XAML and XAP files are associated with Silverlight and downloaded correctly to the Web client machine when requested.
Once the Silverlight plug-in is installed on a Web client machine and a Silverlight application is downloaded, the Silverlight application is then hosted on the Web client machine.

Silverlight 3.0 additional features

Once the Silverlight plug-in is installed on a Web client machine and a Silverlight application is downloaded, the Silverlight application is then hosted on the Web client machine
• New Controls
o Date Picker, Time Picker etc.
• 3D Projection
• Effects
• Child Window.
• Save Dialog box.
• Image Events.
• XAML Element Binding
• Data Bound Controls
o Data Form, Data Pager, Data Grid.
• Charting Controls.
• Out-Of-Browser Application.
• Merge Dictionaries.
• Local, Network Connection API.
• XAP compression.
• Navigation Framework.
• Analytics.
• Chart Controls.
• RIA Services (In Beta).
• Sketch Flow.

XAP (ZAP) File

.XAP file (pronounced "ZAP") is the compressed output file for the Silverlight application. The .xap file includes AppManifest.xaml, compiled output assembly of the Silverlight project (.dll) and any other resource files referred by the Silverlight application. You can see this in bin/debug folder of your project with projectname.zap.


Silverlight execution process

Our whole project including XAML and other sources are compiled into assemblies (.dll). That is the reason we see that every Silverlight project will always be a user control. This assembly is then combined with the assemblies that our project uses and packaged into a .XAP file. This XAP is then read by the Silverlight runtime in the browser and rendered accordingly. If we look into the output while building our Silverlight project, we can see that it is indeed packaged into XAP file. Traversing to the ClientBin folder in our project location we can see the XAP file generated.


Silverlight Tools


• Tools
o Microsoft Expression
 Expression Blend.
 Expression Encoder.
 Deep Zoom.
o Microsoft Visual Studio 2008
 Silverlight 2 SDK.
Microsoft Silverlight functionality is completely encapsulated within the Silverlight plug-in. Silverlight applications simply require a Web server to be equipped as they would be for hosting HTML documents. Silverlight applications can be hosted in any web server.
Platforms that Support Silverlight

Operating System Browser
• Windows Vista
• Windows XP SP2
• Windows 2000
• Windows Server 2003
• Macintosh OS 10.4.8+ (Intel Based) • Internet Explorer 7+
• Firefox 1.5+
• Google Chrome
• Safari

Microsoft has announced support for Silverlight on mobile devices with a limited initial support for Windows Mobile and the Nokia S60 models.

Early Adopters
Few of the early adopters of Silverlight technology are following and many more
Some example sites are listed below:
• World Series of Poker
• Discovery Channel
• The Emmys
• Home Shopping Network (HSN)
• World Wrestling Entertainment (WWE)
• Fox
• XBOX 360
• Netflix - uses Silverlight to allow subscribers to instantly watch movies on their PCs or Intel-based Macs