Discussion Accessing 'Content' elements in dynamically loaded XAP

  • Thursday, February 16, 2012 5:32 AM
     
     

    Hi All,

    First off, my apologies if this has been asked before, but I couldnt find anything when searching, so...

    I have a Silverlight app that may be dynamically loaded at runtime into a MEF framework. This app contains an xml file with the build action set to 'content' (necessary so it can be changed after compilation) and i'm having trouble accessing the file, from the code in the same XAP file, when it has been loaded at runtime.

    If I set the build action to 'resource' it works fine, but this means the file cant be modified later.

    First off, should i be able to do this at all?

    I've tried using Application.GetResourceStream, and all i ever get is a 'null' stream as if the file can't be found or doesn't exist, as below:

    using ( StreamReader sr = new StreamReader( Application.GetResourceStream( new Uri( "<XAPNAME>;component/<FileName>", UriKind.Relative ) ).Stream ) )
    {
        ...
    }

    The file is in the root of the XAP package, and i have checked to make sure it is actually there.

    I should point out i need to specifically access the file in my XAP to ensure that if another XAP contains a file of the same name, i get the correct one

    Any help or suggestions would be gratefully recieved.

All Replies

  • Monday, February 20, 2012 4:40 AM
     
     
  • Monday, February 20, 2012 9:13 AM
     
     

    Hi, thanks for your response.

    However, as mentioned, i need to access content files (with the build action 'content', which puts the file in the XAP file to enable post-deployment editting), rather than resource files (with the build action 'resource', which are embedded in the dll inside the xap file, and cannot be modified) Therefore, while interesting, the link you posted above doesnt help much.

    Thanks again, though

  • Monday, April 30, 2012 5:45 AM
     
     

    Hallo,

    I am having exactly the same problem. Have you found a solution in the meanwhile ?

     

    Thanks