2012-10-18 104 views
0

我得到此錯誤「錯誤CS0103:名稱`HttpUtility'在當前上下文中不存在」 當我嘗試編譯我的c#文件時使用「 $ mcs file.cs「。我添加了「使用System.Web」,並使用單聲道框架在Suse 12.1上運行此操作。我是新來的C#和我下面的教程這裏http://www.codeproject.com/Articles/9407/Introduction-to-Mono-Your-first-Mono-app錯誤CS0103:名稱`HttpUtility'在當前上下文中不存在

這是我file.cs內的代碼

using System; 
using System.Net; 
using System.Web; 
using System.Text; 
using System.Text.RegularExpressions; 

namespace Dela.Mono.Examples 
{ 
     class GoogleSearch 
     { 
       static void Main(string[] args) 
       { 
         Console.Write("Please enter a string to search google for:"); 
         string searchString = HttpUtility.UrlEncode(Console.ReadLine()); 

         Console.WriteLine(); 
         Console.Write("Please wait....\r"); 

         //Query google 
         WebClient webClient = new WebClient(); 
         byte[] response =  webClient.DownloadData("http://www.google.com/search?&num=5&q=" + searchString); 


         //Check reponse results 
         string regex = "g><a\\shref=\"?(?<URL>[^\">]*)[^>]*>(?<Name>[^<]*)"; 
         MatchCollection matches = Regex.Matches(Encoding.ASCII.GetString(response), regex); 

         //output results 
         Console.WriteLine("===== Results ====="); 
           if(matches.Count > 0) 
           { 
             foreach(Match match in matches) 
             { 
               Console.WriteLine(HttpUtility.HtmlDecode(
                 match.Groups["Name"].Value) + 
                 " - " + match.Groups["URL"].Value); 
             } 
           } 
           else 
           { 
             Console.WriteLine("0 results found"); 
           } 
       } 
     } 
} 

可能是什麼問題,以及如何我解決這個問題?

+1

你目標客戶的個人資料?嘗試改變 – V4Vendetta

+0

是的,我似乎System.Web似乎沒有在那裏。那麼,考慮到我使用suse linux,我該如何解決這個問題。 – roykasa

+0

是的,我正在努力工作。謝謝。 – roykasa

回答

1

正如你聯繫,嘗試編譯文章中指出:

$ mcs file.cs -r System.Web.dll 
相關問題