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.
- Create a Silverlight Application
- Compile it to IL.
- Packaged it to XAP file.
- XAP file hosted in web server
- 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,
- Right click XAP file
- Rename the extension from XAP to ZIP
- 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,
- Open Command prompt as administrator
- Type command as below
- 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
- Silverlight application dll
- AppManifest.Xaml file.
AppManifest.xaml file contains key information like,
- Version of Silverlight application is targeting
- Entry point of the application
- 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 Step 1
HTML files gets loaded at client browser Step 2
Browser reads the HTML and finds the object tag and XAP file associated with object tag. Step 3
Browser downloads the XAP file using Silverlight plugin installed at browser.Step 4
Silverlight plugin reads the AppManifest.Xaml file and finds Entry Point of the application and minimum version of Silverlight application is targeting. Step 5
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.