first_page

Silverlight Finery: Packing XAPs

It is my choice to invest hours and hours researching the most “elegant” way to progressively load a Silverlight application. From a time-to-market (including the job market) view this is a “mistake.” This kind of “error” permeates through my IT career.

So there is a Silverlight “star” with the name Amyo who answers a forum post called, “How to change existing SL Class library to SL Application and produces xap file?” His answer provides me with great conceptual leap that gets me closer to updating my resume:

You can convert your SL class library project to SL app project like below:

Class Library Project > Add New Item > Silverlight Application Class

Open the class library project file with notepad and change the following:

<SilverlightApplication>true</SilverlightApplication>

Project property >Silverlight tab > Change the starter object (newly created application class)

Project property >Silverlight tab > Set the XAP file name (i.e. test.xap)

Open the class library project file with notepad Add &lt;XapOutputs&gt;true&lt;/XapOutputs&gt; … <SilverlightApplication>true</SilverlightApplication>.

Now the project is converted and ready.

In your web application project:

Project property >Silverlight tab > Add your Silverlight app (converted one) that will generate the .xap file.

My few-minutes work with these instructions tells me that:

  • It is not a requirement to add an application class to the converted project. In MEF scenarios leaving out this step is useful.
  • Adding AppManifest.xml to the project is useful. So adding the project file elements &lt;GenerateSilverlightManifest&gt;true&lt;/GenerateSilverlightManifest&gt; and &lt;SilverlightManifestTemplate&gt;Properties\AppManifest.xml&lt;/SilverlightManifestTemplate&gt; works. Of course an actual AppManifest.xml file is needed.
  • Strategically setting Copy Local to False for referenced assemblies to prevent multiple copies of assemblies in XAP files looks like a fine art to me. Still working on this…

rasx()