0

I created a method in console to read an online xml file and it worked just fine. Transfer the same code to a windows form application and I get the following error:

Exception thrown: 'System.Net.WebException' in System.Xml.dll The underlying connection was closed: An unexpected error occurred on a send.

This is the relevant code and it stops on the reader.movetocontent() line.

I'm not an advanced programmer and don't understand why it works in console but not in windows form program.

string downloadUrl = "";
Version newVersion = null;
string xmlUrl = "https://sourceforge.net/projects/bookbindingsections/files/CurrentVersion.xml";
XmlTextReader reader = null;
try
{
    reader = new XmlTextReader(xmlUrl);
    reader.MoveToContent();

Visual Studio Community Edition 2017 Windows 10

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
shags_j
  • 11
  • 2
  • I've just tried to run your code in a `WinForms` application (.NET framework 4.6) it worked just fine – Fabjan Apr 22 '18 at 11:53
  • Thank you so much. It was the .NET framework. I had 4.5.2 selected. Updated to 4.6 and worked. Cheers. – shags_j Apr 22 '18 at 11:56

0 Answers0