This action might not be possible to undo. Are you sure you want to continue?
This article is reproduced here with the permission of VSJ, the magazine where it was originally published. If you're a professional software developer based in the UK, you can claim a free annual subscription to VSJ.
So you want fancy, sexy streaming media in the UI? And you want cool animations, fancy glow-in-the-dark buttons and decent, scalable vector graphics? And you want to run your application in a browser on both Windows and Mac OSX? If you’re already reaching for your copy of How to Wow with Flash, stop. There’s a new kid muscling onto the somewhat crowded Rich Interactive Application (RIA) block, and it’s coming from Microsoft. Formerly known as WPF/E, Silverlight has been garnering some serious attention since it was first announced way back at the PDC in 2005. In this article, I’ll take you on a guided tour of Silverlight 1.0, introducing both the technology behind it and how it fits into both the .NET and RIA application landscapes. Specifically, I’ll highlight some of Silverlight’s capabilities as we look at building a simple media player, as shown in Figure 1.
Figure 1: The MediaCenter application
So what is Silverlight?
At its simplest, Silverlight is a plug-in that renders XAML-based user interfaces within a browser. Specifically, it supports modern incarnations of Internet Explorer 6+, Firefox 1.5+ & 2 and Safari 2 on the latest Windows (XP, Server 2003 and Vista) and Mac OS X platforms. Freely downloadable from Microsoft, the plug-in weighs in at a few megabytes, but it does contain some neat features, including the ability to update itself automatically and, more importantly, support for playing different media formats (VC-1, WMA and MP3) without requiring either the .NET Framework or Windows Media Player to be present on the client. There is, however, much more to Silverlight than just a simple browser plug-in for playing some media files. For example, Microsoft is currently working on a new service, snappily entitled “Microsoft Silverlight Streaming by Windows Live”, which provides an online home for Silverlight applications and their corresponding media content for those who don’t want to set up their own media-streaming facilities.
Figure 2 provides a very high level overview of the architecture of a basic Silverlight application.
Figure 2: Silverlight 1.0 architecture
Could Silverlight 1.1 assemblies be generated with Visual Studio .NET 2005? Well, if you read the GetStarted page of Silverlight you see only upcoming Visual Studio codename Orcas as development platform. Bryant asked this in the Silverlight forum and got a great answer from Scott Louvau. He replied: Well, in VS2005 you can create a class library which will build against the Silverlight runtime, but it's a little work. 1. 2. 3. 4. 5. Create a Class Library. Remove all references from it. Right-click on the Project and pick Properties. On the Build tab, click Advanced and check 'Do not reference mscorlib.dll' Manually add references to mscorlib, agclr, System, System.Core, System.Silverlight, and System.Xml.Core from the Silverlight install folder (\Program Files\Microsoft Silverlight\)
At this point your build outputs should be Silverlight consumable binaries. It looks like the equivalent command line call to csc.exe (the C# compiler) should include the references to the mentioned binaries and the /nostdlib option but may require others as well. You will find an Hello World example on Bryant's blog here. Feel free to download it and try it with Visual Studio .NET 2005. Don't forget to first install Silverlight 1.1.