Nov 072009

Silverlight is Microsoft’s answer to Adobe Flash, used to display multimedia, animation and graphics in Internet applications. Its a subset of Windows Presentation Foundation and uses a vector graphics rendering engine to deliver much better graphics than conventional web images.

With each release Microsoft is working on bringing Silverlight and WPF closer to each other. Prism is one such implementation which allows applications to be written without knowing the end platform in mind. In this blog I will explain how to write a simple application and XCOPY deploy it to a shared web hosting provider, in my case godaddy.

First open up Visual Studio. For this walkthrough I have used Visual Web Developer 2008 which is a free software and can be downloaded here. You would also need the Silverlight SDK consisting of the runtime environment and the toolkit, all of which can be downloaded at the Silverlight page.

First open up Visual Web Developer. Click on File -> New Project. If the tools were installed correctly, you should see a new Project type Silverlight Application in the list.


The next screen asks if you want to host your silverlight application in an ASP.NET website. This is really optional since Silverlight is independant from ASP.NET. It can be hosted on your HTML, PHP, JSP application with equal ease. The only thing needed is the .XAP file.


The solution is created and if you look at it there, are two projects. One is the Silverlight project with App.xaml and MainPage.xaml. Another project is the ASP.NET website which is the host for the Silverlight application. The xap file is contained in the ClientBin folder.


In the godaddy Hosting manager, click on IIS management and create a virual directory which is setup as an application.


Now lets see the project. Click on MainPage.xaml to see the markup for the MainPage. Copy this markup between the grid element. Unfortunately the HTML tags aren’t working properly when I copy paste them to the blog. Hence posting the screenshot.


Then you need to modify the web.config and set the custom errors mode = off. Then using a FTP client copy all the host website files into the virtual directory that you created. And thats it. Your first sample silverlight website.