locked
Modify Xap file RRS feed

  • Question

  • Hi,

    I deployed a Silverlight 4 application that use a WCF Service to retrive the data. Therefore, I have a service reference in my Xap file. At the moment, the application and the service are not deployed. The next step is therefore to deploy it. What I would like to do is to publish my application then publish my service and at the end, modify the service reference in the Xap file to set the new one.

    Is it possible to do that?

    Thanks.

    Friday, September 17, 2010 11:28 AM

Answers

  • What you usually would do is:

    1. Use different configurations for developing/testing and deployment, where all the references are already there and picked as part of the build process (by build configurations, with build events, custom scripts, etc.). Or

    2. Determine the service reference on the client automatically. If the service is located on the same server the Silverlight application is hosted on, you can use the site of origin and the relative location of the service to dynamically build the correct service reference at run time. That way you never have to worry that the reference breaks when you deploy the application somewhere else.

    Edit: of course, since the XAP file is only a zip archive, you could try and temporarily unpack the contents, change the reference and recompress everything. It's just that I've not seen someone do that when there are other, simpler possibilities.

    Friday, September 17, 2010 12:45 PM

All replies

  • What you usually would do is:

    1. Use different configurations for developing/testing and deployment, where all the references are already there and picked as part of the build process (by build configurations, with build events, custom scripts, etc.). Or

    2. Determine the service reference on the client automatically. If the service is located on the same server the Silverlight application is hosted on, you can use the site of origin and the relative location of the service to dynamically build the correct service reference at run time. That way you never have to worry that the reference breaks when you deploy the application somewhere else.

    Edit: of course, since the XAP file is only a zip archive, you could try and temporarily unpack the contents, change the reference and recompress everything. It's just that I've not seen someone do that when there are other, simpler possibilities.

    Friday, September 17, 2010 12:45 PM
  • Well, I've done it (modifying the xap) for a variety of reasons.  One of them is to stick a timestamp file into the xap.  As MisterGoodcat said it is just a zip file, and I use 7zip to stuff something into the xap post-build.  It is just that it shouldn't be done too often, as this adds complexity to the build process (harder to maintain).  I just had a need that wasn't elegantly solved otherwise.

    Friday, September 17, 2010 1:10 PM
  • 2. Determine the service reference on the client automatically. If the service is located on the same server the Silverlight application is hosted on, you can use the site of origin and the relative location of the service to dynamically build the correct service reference at run time. That way you never have to worry that the reference breaks when you deploy the application somewhere else.


    This seems like a great solution, can you please provide a little more detail on how exactly to implement this?  I googled for "site of origin" and "relative location" for wcf services and found nothing...  Thanks.

    Sunday, March 13, 2011 7:24 PM
  • Hi. Tony has written an article about that here. Hope this helps.


    Sunday, March 13, 2011 7:43 PM