Professional, Software


Silverlight app file (.XAP) is essentially a zip file. For testing purposes, many times we needed to look inside the XAP file from customers to see what was causing an issue.

It is possible to day to see what exactly is inside the .Xap file today but it involves few  steps….

  1. Extract all the contents out of Zip file
  2. you should be having bunch of resource files (.mpg, jpg, .wmv etc) and assemblies (.dll) and Application manifest (app.xaml)
  3. Then most of the pages etc are embedded in the assembly so now you can use one of the tools (such as ILDASM) to extract resources out of there to see what is embedded in side assembly

In short it was kind of painful process. I wanted to write some utility assembly that exposes all this information out of Xap in a easier way. These utility APIs could be used to build UI around it.

[Before we get into details of PAX, big Thanks to Eduardo for helping me cleanup the code and fix some of the issues]

There are two DLLs….


This DLL contains classes and APIs that read the Zip (Deflate) format that is used for creating .Xap files for silverlight. It has following classes



This class represents a zip file. It exposes the Files collection that are inside zip as well as ReadFiles method that reads individual files (stored in Files Collection).


This class represents individual files inside Zip file. Every ArchiveFile has ArchiveFileHeader as well as method ReadFile to read the file. ReadFile method is actuall what decompresses the content using DeflateStream class.


Each file in the zip format has a header. Header contains lot of information that is used to read the actual content of the file. Header exposes properties such as Compressed/Uncompressed size, last modified date, filename etc


This is a utility class that converts the array of Bytes into types that are needed for PAX.


This DLL that contains classes and APIs that introduces the concept of XAP. e.g. Every XAP has a manifest file, it can contain assemblies and resources etc. It has following classes




This class represents individual XAP file. It exposes Files collection that contains individual files inside Xap. It also exposes property for manifest.

File and its Sub classes

This class represents generic file inside a xap. File is a base class for different type of files (assemblyfile, manifestfile, xamlfile etc). File can be inside xap or inside assembly. Currently only ManifestFile class implements validation logic using Schemas but in general every file class could have some validation logic. That is the reason why VideoFile/AudioFile classes exists but are empty today.


This class represents the metadata about a file in xap such as  compressed size, uncompressed size etc

Use of Pax

Here is a very simple way I can use the PAX to list the properties of files inside a given xap.

using System;
using XapModel;
using System.IO;

namespace PaxConsoleTest
    class Program
        static XapArchive _xap;

        static void Main(string[] args)
            using (FileStream fs = new FileStream("TestPax.xap", FileMode.Open))
                _xap = new XapArchive(fs);
                foreach (XapModel.FileTypes.File file in _xap.Files)
                    if (file is XapModel.FileTypes.AssemblyFile)
                        foreach (XapModel.FileTypes.File embeddedfile in 
((XapModel.FileTypes.AssemblyFile)file).Resources) { WriteFileProperties(embeddedfile); } } } } } private static void WriteFileProperties(XapModel.FileTypes.File file) { Console.WriteLine(); Console.WriteLine("************************************"); Console.WriteLine( "File Name: " + file.FileProperties.FileName + " Last Modified: " + file.FileProperties.LastModified); Console.WriteLine( "Compressed Size: " + file.FileProperties.CompressedSize + " Uncompressed Size: " + file.FileProperties.UncompressedSize); Console.Write("************************************"); Console.WriteLine(); } } }

which produces output such as


File Name: AppManifest.xaml         Last Modified: 10/22/2008 10:06:14 PM

Compressed Size: 300         Uncompressed Size: 337



File Name: TestPax.dll         Last Modified: 10/22/2008 10:06:14 PM

Compressed Size: 21189226         Uncompressed Size: 21720064



File Name: TestPax.g.resources/page.xaml         Last Modified: 1/1/0001 12:00:00 AM

Compressed Size: 0         Uncompressed Size: 286



File Name: TestPax.g.resources/asmembedded/asmembeddedvideowmv.wmv         Last Modified: 1/1/0001

2:00:00 AM

Compressed Size: 0         Uncompressed Size: 4045744



File Name: TestPax.g.resources/asmembedded/asmembdimgjpeg.jpeg         Last Modified: 1/1/0001 12:

:00 AM

Compressed Size: 0         Uncompressed Size: 3495

Technorati Tags: ,,,

Here is the link to code to code for Pax


3 thoughts on “Pax

  1. Pingback: Pax-Reflector Plugin « Desperately Seeking Love of Sophie

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s