What is purpose of the XAP file in Silverlight

No.of Views773
Bookmarked0 times
Downloads 
Votes0
By  Dhananjay Kumar   On  19 Apr 2011 10:04:54
Tag : Silver Light and XAML , General
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.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

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. 

Image Loading

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,

Image Loading

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.

Image Loading

 

Every time you run Silverlight application, automatically visual studio creates the XAP file and deploy to the web site. 

Image Loading
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. 
Image Loading
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 
 
Image Loading
3.Navigate to folder containing XAP file. On right click of XAP file you can find  Extract All option.
Image Loading

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. 

Image Loading

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.

Image Loading
Algorithm how Silverlight application loads at client browser 
Step1 
HTML files gets loaded at client browser 
Step2
Browser reads the HTML and finds the object tag and XAP file associated with object tag. 
 
Image Loading
 
Step3
 
Browser downloads the XAP file using Silverlight plugin installed at browser. 
 
Step4
 
Silverlight plugin reads the AppManifest.Xaml file and finds Entry Point of the application and minimum version of Silverlight application is targeting. 
 
Step5 
 
Application gets executed at client browser. 
Size of the XAP file is vital factor in performance of Silverlight application. 
 
Image Loading

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. 

 
Sign Up to vote for this article
 
About Author
 
Dhananjay Kumar
Occupation-Software Engineer
Company-Infosys Technolgies,Pune
Member Type-Gold
Location-India
Joined date-20 Jul 2009
Home Page-http://dhananjaykumar.net/
Blog Page-http://dhananjaykumar.net/
Dhananjay Kumar is Microsoft MVP on connected system. He blogs at http://dhananjaykumar.net/ . You can follow him http://twitter.com/debugmode_/ and reach him at dhananjay.25july@gmail.com
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top