Overview
As we all know, when Silverlight 2 starts each project to be packaged into a xap file, how do we access the contents of an external XAP file if we want to access the UserControl in the current XAP file? How do you even access a XAP file on the Internet?
Demand
Now let's take a look at the requirements, roughly like this, we have two XAP files on the server, where the mainproject.xap files will be Mainprojecttestpage.aspx, and the UserControl in the Externalproject.xap file will be accessed in the Mainproject.xap file and displayed as shown in the following illustration:
Now we're going to build the relevant project and the final project structure as shown in the following illustration:
This will result in the creation of two. xap files under the ClientBin folder, and now we will access UserControl in Externalproject.xap in the Mainproject.xap file.
Analysis
In implementing this process, we will encounter two problems:
1. Because there are no pages referencing the Externalproject.xap file, it will not be downloaded to the client, which we can download by encoding.
2. To access the UserControl in Externalproject.xap, we need to find the corresponding assembly in order to use reflection, and we know that the XAP file is a standard zip file that contains the relevant assembly (next I will write an article specifically explaining the XAP file) , as shown in the following illustration:
Now that we have solved the problem of the access of the XAP file to the assembly, we can proceed to implement it.