2015-12-23 3 views
1

Мои ошибки в C# и idk, почему он говорит мне, что пространство имен XmlTextReader не найдено. И у меня есть такая же ошибка с XmlNodeType, говоря, что ее не удалось найти. Как это исправить?Не удалось найти пространство имен XmlTextReader/XmlNodeType, как исправить?

Вот мой код:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace Updater 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string downloadUrl = " "; 
    Version newVersion = null; 
    string xmlUrl = "http://www.mywebsite.com"; 
    XmlTextReader reader = null; //The error here says that XmlTextReader could not be found 
    try 
    { 
     reader = new XmlTextReader(xmlUrl); 
     reader.MoveToContent(); 
     string elementName = " "; 
     if((reader.NodeType == XmlNodeType.Element) && (reader.Name == "EastPerlUpdater")) //XmleNodeType is another error that shows saying doesnt exist in current context, but its all over the place!! 
     { 
      while(reader.Read()) 
      { 
       if(reader.NodeType == XmlNodeType.Element) //Again with the XmlNodeType error, and so on. 
       { 
        elementName = reader.Name; 
       } 

       else 
       { 
        if((reader.NodeType == XmlNodeType.Text) && (reader.HasValue)) 
        { 
         switch(elementName) 
         { 
          case "version": 
          newVersion = new Version(reader.Vaule); 
          break; 
          case "url": 
          downloadUrl = reader.Vaule(); 
          break; 
         } 
        } 
       } 
      } 
     } 
    } 
    catch (Exception ex) 
    { 

    Console.WriteLine(ex.Message); 
    Environment.Exit(1); 

    } 
    finally 
    { 
     if (reader != null) 
      reader.Close(); 
    } 
    Version applicationVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; 
    if (applicationVersion.CompareTo(newVersion) < 0) 
    { 
     Console.WriteLine("Version " + newVersion.Major + "." + newVersion.Minor + "." + newVersion.Build + "A new version of East Perl Hub is available, want to download? Y/N"); 
     string userInput = Console.ReadLine(); 
     if (userInput == "Y") 
     { 
      System.Diagnostics.Process.Start(downloadUrl); 
     } 

     else 
    { 
     Console.WriteLine("This app is up to date"); 
    } 

    } 
     } 
    } 
} 

ответ

1

Убедитесь System.Xml включен в качестве ссылки в проекте, и вы добавили правильный, используя для этого заявления.

+0

Ну, я буду проклят, Idk, как я пропустил это. Спасибо огромное! – Remi

Смежные вопросы