none
Accessing 'Content' elements in dynamically loaded XAP

    General discussion

  • 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.

    Thursday, February 16, 2012 5:32 AM

All replies