Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:56:23+00:00 2026-05-31T00:56:23+00:00

I am trying to figure out how to port some .Net code that parsed

  • 0

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 The given System.Uri cannot be converted into a Windows.Foundation.Uri, I have the below code. Still, I get stuck immediately after I create the Uri:

    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);
        }
    }

I get an unhandled exception when I try to call XmlDocument.LoadFromUriAsyn(uri):

ArgumentException was unhandled by the user code – Value does not fall within the expected range.

Anyone else feel like everything is 10 times harder with WinRT?

EDIT:

I have tried all the following strings, and get the exact same error:

  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

Project Set Up:

Project

  • Properties
  • References
  • Assets
  • Data
    • world.xml
  • Source code…

In Code:

  filePath = "Data\\world.xml";

I have also tried putting the xml file under assset\data, and just assets. Nothing seems to make a difference.

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.

Full Exception details:

System.ArgumentException was unhandled by user code

HResult=-2147024809

Message=Value does not fall within the expected range.

Source=Windows.Data.Xml.Dom

StackTrace:

at Windows.Data.Xml.Dom.XmlDocument.LoadFromUriAsync(Uri uri, XmlLoadSettings loadSettings)

at Crystal.IO.File.XmlFileSerializer.d__1.MoveNext() in d:\Projects\Crystal\library\IO\File\XmlFileSerializer.cs:line 32

InnerException:

Download the smallest example possible to repro the issue: test_xml.zip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:56:24+00:00Added an answer on May 31, 2026 at 12:56 am

    I finally figured it out after I looked at Windows Runtime Xml data API sample.

        public override async Load()
        {
            var file = await GetPackagedFile("assets", "world.xml");
            LoadXml(file);
        }
    
        private async void LoadXml(StorageFile file)
        {
            XmlLoadSettings settings = new XmlLoadSettings() { ValidateOnParse = false };
            XmlDocument xmlDoc = await XmlDocument.LoadFromFileAsync(file, settings);
    
            foreach (IXmlNode xmlNode in xmlDoc.ChildNodes)
            {
                //ProcessNode(xmlNode);
            }
        }
    
        private async Task<StorageFile> GetPackagedFile(string folderName, string fileName)
        {
            StorageFolder installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
    
            if (folderName != null)
            {
                StorageFolder subFolder = await installFolder.GetFolderAsync(folderName);
                return await subFolder.GetFileAsync(fileName);
            }
            else
            {
                return await installFolder.GetFileAsync(fileName);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out some C code so that I can port it
I'm trying to figure out how to redirect output from some FORTRAN code for
Trying to figure out how to write a jquery formula that will sum all
Trying to figure out this pseudo code. The following is assumed.... I can only
I've been given some Symbian C++ code to port over for use with the
I am trying to create a .bat file that starts the ASP.NET Dev Server
While trying to port some code to compile in linux I get peculiar compilation
I am trying to figure out how to create a java program that can
I've been banging my head trying to figure some things out. So, I'm looking
I am trying to port some Delphi XE code to XE2, it uses a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.