What is AppManifest.xaml in Silverlight?


Many of you don't aware of it in depth, mainly the freshers who just started doing their hands dirty with the light of Silver. In this post I am going to describe you about AppManifest.xaml file and it's uses in depth. Read the complete post to know more about it.

 

Don't forget to leave your feedback and/or any queries at the end of this post. Appreciate for reading this post.

 

 

The AppManifest.xaml file contains the deployment details needed to run the Silverlight application. The first element of it starts with a Deployment node which defines the Assembly information, Runtime version, Application Entry point and the assembly, extension parts.

 

You can find the complete AppManifest.xaml file inside the .XAP file. It is also available in the Silverlight project's Properties folder (named as "AppManifest.xml"), but you will find it almost empty there. Once you build your project, it gets generated by the IDE and placed inside your XAP file.

 

To find out it, build your solution and go to your Client Bin folder. Open your .XAP with a Zip utility. If you are unable to open that file, rename it to .Zip extension. You will be able to open now.

 

image

 

 

Once you open the AppManifest.xaml file, you will see the following code there:

 

 
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            EntryPointAssembly="AppManifestDemo1" 
            EntryPointType="AppManifestDemo1.App"
            RuntimeVersion="4.0.50826.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="AppManifestDemo1" Source="AppManifestDemo1.dll" />
  </Deployment.Parts>
</Deployment>

 

 

The root element is the Deployment node. It defines the Entry Point Assembly, Entry Point Type (basically the main application class name with full namespace) and the Silverlight Runtime Version.

 

This node contains the Deployment.Parts and/or Deployment.ExternalParts as the child. The Deployment.Parts defines the Assembly Parts those are referenced in the project and present in the .XAP file. It also defines the main output dll as the Assembly part. As shown in the above figure, we have only one assembly in our XAP (the main project output) and hence only one entry in the AppManifest.xaml file.

 

Let's add some more external dependencies in our project. Build it and open the XAP once again. Now you will see that in our latest xap, we have the external assemblies too (as highlighted below).

 

 

 

If you open the AppManifest.xaml file now, you will notice that, it contains those dlls as Assembly Parts in the Deployment.Parts section.

 
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            EntryPointAssembly="AppManifestDemo1" 
            EntryPointType="AppManifestDemo1.App" 
            RuntimeVersion="4.0.50826.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="AppManifestDemo1" Source="AppManifestDemo1.dll" />
    <AssemblyPart x:Name="SilverlightClassLibrary1" Source="SilverlightClassLibrary1.dll" />
    <AssemblyPart x:Name="System.Json" Source="System.Json.dll" />
  </Deployment.Parts>
</Deployment>

 

 

Now let's discuss on the Deployment.ExternalParts section. You will find this section if you have enabled the Application Library Caching. Enable the Application Library Caching in your project as shown in this post. Now build your solution once again. You will not see those external assemblies in your XAP now. They will be part of separate .Zip files placed inside your Client Bin directory.

 

Open your AppManifest.xaml file and you will see the below changes:

 
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            EntryPointAssembly="AppManifestDemo1" 
            EntryPointType="AppManifestDemo1.App" 
            RuntimeVersion="4.0.50826.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="AppManifestDemo1" Source="AppManifestDemo1.dll" />
    <AssemblyPart x:Name="SilverlightClassLibrary1" Source="SilverlightClassLibrary1.dll" />
  </Deployment.Parts>
  <Deployment.ExternalParts>
    <ExtensionPart Source="System.Json.zip" />
  </Deployment.ExternalParts>
</Deployment>

 

 

You will notice that, it removed the external dependencies from the deployment part section and added it inside the deployment external part section. Also notice that, it's not referencing the dll, instead it is pointing to the zip file that has been created by the IDE in the Client Bin directory.

 

Hope this helped you to understand the AppManifest file of your Silverlight application. Let me know, if you have any queries. Also, don't forget to share your thoughts and/or feedbacks at the end of the post.


If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter , Facebook , Google+ and LinkedIn . I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.

14 comments

  1. I thought of writing the same, but you did it before I do. Good work mate

    ReplyDelete
  2. Ha ha ha. I didn't know about it. BTW, thanks Abhishek Sur for the feedback.

    ReplyDelete
  3. adding my knowledge... to make an assembly as a part of External parts nodes, we need to do two things
    1. Sign the assembly with strong name key.
    2. create an xml file with the name .extmap.xml and with following content.
    (The xml file does not have to be included in the assembly, but needs to exist in the same physical place as your assembly)

    for example if you want to have your assemly MSIT.PhysicsHelpers.dll as part of external parts node

    then xml file name should be MSIT.PhysicsHelpers.extmap.xml

    and content of xml should be

    MSIT.PhysicsHelpers 1.0.0.0 *key goes here* MSIT.PhysicsHelpers.dll

    Thanks
    HobbyDotNet

    ReplyDelete
  4. I don't think it is related to the post.

    Regards,
    Kunal

    ReplyDelete
  5. My intention is that only assemblies with
    extmap.xml files
    can be part of Deployment.ExternalParts node...

    ReplyDelete
  6. Yes, you are absolutely right in that case.

    ReplyDelete
  7. Thanks for the valuable post.it is soo much helpful.

    ReplyDelete
  8. Thanks Kunal.

    This is very useful blog.

    ReplyDelete
    Replies
    1. Thnks Kunal It helps me but I want to differentiate the code into multiple .xap file is this possible in Silverlight?

      Delete
    2. Hi Tejas,

      Glad to hear that, it helped you. BTW, can you tell me what do you mean by "want to differentiate the code into multiple .xap file"?

      Delete
  9. Great to know the relation of appManifest.xaml and XAP.
    For my WP8 projects exactly the xaml file is not generated (nor part of XAP file). When creating new HTML project (VS2012, Win8.1), the xaml file gets generated (bin/debug) and as part of XAP.
    This results in your app dll not being loaded (modules) and your device showing "loading" forever.
    I did compare existing and new projects carefully w/o any success.

    ReplyDelete
  10. Realy great post by you ,
    Thanx sir

    ReplyDelete
  11. Realy Great post by you,
    It increase my knowledge.
    Thanx

    ReplyDelete


 
© 2008-2016 Kunal-Chowdhury.com - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top