locked
XDocument.Load throws System.IO.IOException: Too many files opened. RRS feed

  • Question

  • User354273 posted

    System.IO.IOException: Too many files opened.

    In the PCL project I am using XDocument.Load(filePath) to read Xml files, It's used with a click event with shapes, and seems to have no correlation with the number of times XDocument.Load is called.

    I found that the exception is coming from XmlReader.Create() There are no issues when using this with UWP.

    I've searched everywhere for a solution to this issue, with no luck.

    Has anyone else ran into this issue, or knows of any solution to fix this issue?

    Thank you,

    Garrick

    Wednesday, October 18, 2017 6:34 PM

Answers

  • User354273 posted

    So here was my issue,

    A new HttpClient was being created every time, which is used to check connections and login status. Changing it to a static variable and having all calls share it seems to have fixed my initial issue.

    Found a nice blog describing the correct way to use HttpClient, which I cannot link.

    Hope this helps someone in the future.

    Thank you,

    Garrick

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, October 18, 2017 9:42 PM

All replies

  • User354273 posted

    Is HttpClient.GetAsync() considered an "open file" for iOS? If so, that might be the issue.

    Can anyone confirm?

    Thanks!

    Wednesday, October 18, 2017 7:20 PM
  • User354273 posted

    So here was my issue,

    A new HttpClient was being created every time, which is used to check connections and login status. Changing it to a static variable and having all calls share it seems to have fixed my initial issue.

    Found a nice blog describing the correct way to use HttpClient, which I cannot link.

    Hope this helps someone in the future.

    Thank you,

    Garrick

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, October 18, 2017 9:42 PM