Target Audience: Beginners in Silverlight
When you start learning Silverlight and create your first Silverlight application, one thing you will notice XAP file along with HTML and ASPX files. First time after running your Silverlight application you can see XAP file in client bin folder. Before running of Silverlight application, you will not find XAP file in client bin folder.
Usually below steps followed while running a Silverlight application.
1. Create a Silverlight Application
2. Compile it to IL.
3. Packaged it to XAP file.
4. XAP file hosted in web server
5. XAP file get downloaded to browser.
Flow diagram of a Silverlight application from creation to running at client browser can depicted as below,
If you notice whenever we are creating a new Silverlight application, you usually host Silverlight application in a new Web Site. This is the web site which will host the XAP file.
Every time you run Silverlight application, automatically visual studio creates the XAP file and deploy to the web site.
XAP file is basic deployment in Silverlight.
XAP file is a ZIP file. It contains many files needed to run Silverlight application at the client browser. There are many files contained in a XAP file.
Just to have a look what all files a XAP file contains,
1. Right click XAP file
2. Rename the extension from XAP to ZIP
3. Un Zip the ZIP file. You will find below files inside XAP file
There is one more way to easily extract the entire XAP file. Follow the steps as below,
1. Open Command prompt as administrator
2. Type command as below
3. Navigate to folder containing XAP file. On right click of XAP file you can find Extract All option.
After extracting XAP file on unzipping the Zip file, you can see there are at least two files
1. Silverlight application dll
2. AppManifest.Xaml file.
AppManifest.xaml file contains key information like,
1. Version of Silverlight application is targeting
2. Entry point of the application
3. Name of the Silverlight application to be loaded
If you open AppManifest.xaml file, you will see above information are provided there. There is only one assembly of Silverlight application is listed in Deplyment.Parts section. If you have referred any other assembly in Silverlight application then information of that assembly will also be listed in Deployment.Parts section.
Algorithm how Silverlight application loads at client browser
HTML files gets loaded at client browser
Browser reads the HTML and finds the object tag and XAP file associated with object tag.
Browser downloads the XAP file using Silverlight plugin installed at browser.
Silverlight plugin reads the AppManifest.Xaml file and finds Entry Point of the application and minimum version of Silverlight application is targeting.
Application gets executed at client browser.
Size of the XAP file is vital factor in performance of Silverlight application.
For better performance we should try to have size of XAP file as low as possible. All the resource files, images and Videos should be downloaded asynchronously at client browser. We should put images and media files on the server.
Leave a Reply