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.

clip_image001

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,

clip_image003

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.

clip_image004

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.

clip_image005

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.

clip_image006

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

clip_image007

3. Navigate to folder containing XAP file. On right click of XAP file you can find Extract All option.

clip_image008

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.

clip_image010

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.

clip_image012

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.

clip_image014

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.

clip_image015

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.

Advertisements

8 thoughts on “What is XAP file in Silverlight?

  1. Pingback: DotNetShoutout
  2. Thank you. Have you ever run in to issues with error 2104? This is where .xap can’t be downloaded from website. I’ve tried registering all the MIME types on the web server and still get the same error. IIS 6.0. All blogs point to MIME but not helping

  3. Hi,

    i want to play video file in media element control from web server Client Bin directory, i m using following code :

    string strVideo = “/rtuner.wmv”;
    Uri VideoUri = new Uri(App.Current.Host.Source, strVideo);
    meVideo.Source = VideoUri;
    meVideo.Play();

    using above code video never play , give a problem on above code why video file is not play

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s