title: How to open a packaged file with WinRT
body: <p>I am trying to figure out how to port some .Net code that parsed an xml file to WinRT. So far, with the help of <a href="https://stackoverflow.com/questions/7569720/the-given-system-uri-cannot-be-converted-into-a-windows-foundation-uri">The given System.Uri cannot be converted into a Windows.Foundation.Uri</a>, I have the below code. Still, I get stuck immediately after I create the Uri:</p>
  
  <pre><code>    static readonly Uri ResourcesBase = new Uri(@"ms-resource://MyAssembly/"); 
      public override async void Load()
      {
          Uri uri = new Uri(ResourcesBase, filePath); // filePath = "Data//world.xml";
          XmlLoadSettings settings = new XmlLoadSettings() { ValidateOnParse = false };
  
          XmlDocument xmlDoc = await XmlDocument.LoadFromUriAsync(uri, settings);
  
          foreach (IXmlNode xmlNode in xmlDoc.ChildNodes)
          {
              ProcessNode(xmlNode);
          }
      }
  </code></pre>
  
  <p>I get an unhandled exception when I try to call XmlDocument.LoadFromUriAsyn(uri):</p>
  
  <p>ArgumentException was unhandled by the user code - Value does not fall within the expected range.</p>
  
  <p>Anyone else feel like everything is 10 times harder with WinRT?</p>
  
  <p>EDIT:</p>
  
  <p>I have tried all the following strings, and get the exact same error:</p>
  
  <pre><code>  Uri uri = new Uri("ms-resource://MyAssembly//" + filePath);
    Uri uri = new Uri("ms-resource://MyAssembly/" + filePath);
    Uri uri = new Uri("d:\\projects\\crystal\\" + filePath); // A valid absolute path
  </code></pre>
  
  <p>Project Set Up:</p>
  
  <p>Project</p>
  
  <ul>
  <li>Properties</li>
  <li>References</li>
  <li>Assets</li>
  <li>Data
  
  <ul>
  <li>world.xml</li>
  </ul></li>
  <li>Source code...</li>
  </ul>
  
  <p>In Code:</p>
  
  <pre><code>  filePath = "Data\\world.xml";
  </code></pre>
  
  <p>I have also tried putting the xml file under assset\data, and just assets. Nothing seems to make a difference.</p>
  
  <p>Another thing, I have the Build Action of the xml set to "Content". Is that correct? The only other thing I could imagine that it would be is "Embedded Resource" but I doubt it.</p>
  
  <p>Full Exception details:</p>
  
  <p>System.ArgumentException was unhandled by user code</p>
  
  <p>HResult=-2147024809</p>
  
  <p>Message=Value does not fall within the expected range.</p>
  
  <p>Source=Windows.Data.Xml.Dom</p>
  
  <p>StackTrace:</p>
  
  <p>at Windows.Data.Xml.Dom.XmlDocument.LoadFromUriAsync(Uri uri, XmlLoadSettings loadSettings)</p>
  
  <p>at Crystal.IO.File.XmlFileSerializer.d__1.MoveNext() in d:\Projects\Crystal\library\IO\File\XmlFileSerializer.cs:line 32</p>
  
  <p>InnerException: </p>
  
  <p>Download the smallest example possible to repro the issue: <a href="http://crystalcloud.net/downloads/test_xml.zip" rel="nofollow noreferrer">test_xml.zip</a></p>