展现C# 中的一段程序:
using System;
using System.Net;
using System.IO;
using System.Text;
 
public class RequestWebPage
{
private const int BUFFER_SIZE = 128;
private string m_strURL;
 
public RequestWebPage()
{
}public RequestWebPage(string strURL)
{
m_strURL = strURL;
 }
 
 public string URL
 {
 get { return m_strURL; }
 set { m_strURL = value; }
 }
 public void GetContent(out string strContent)
 {
 // 检查 URL
 if (m_strURL == "")
 throw new ArgumentException("URL must be provided.");
 
 WebRequest theRequest = (WebRequest) WebRequestFactory.Create(m_strURL);
 WebResponse theResponse = theRequest.GetResponse();
 // 给回应设置字节缓冲区
 int BytesRead = 0;
 Byte[] Buffer = new Byte[BUFFER_SIZE];
 
 Stream ResponseStream = theResponse.GetResponseStream();
 BytesRead = ResponseStream.Read(Buffer, 0, BUFFER_SIZE);
 
 //使用 StringBuilder 以加速分配过程
 StringBuilder strResponse = new StringBuilder("");
 while (BytesRead != 0 ) 
 {
 strResponse.Append(Encoding.ASCII.GetString(Buffer,0,BytesRead));
 BytesRead = ResponseStream.Read(Buffer, 0, BUFFER_SIZE);
 }
 
 // 赋给输出参数
 strContent = strResponse.ToString();
 }
 }
我在Visual Studio 2005中用命令行编译:
csc /r:System.Net.dll /t:library /out:wrq.dll webrequest.cs结果提示我:
error CS0006: 未能找到元数据文件“System.Net.dll”
怎么解决!
装完C#还需要配置什么吗?(比如像java中的path)

解决方案 »

  1.   

    可能是环境变量被改动了,这个动态链接库在C:\WINDOWS\Microsoft.NET\Framework\YouVersion目录下
      

  2.   

    怎么设置啊?
    我装完VS2005,也没见到VS对环境变量有所改动啊!
      

  3.   

    你用绝对路径试试?环境变量:
    右击“我的电脑”-“属性”-点“高级”选项卡-点“环境变量”-在“path”里加入 (如我的是 C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322)
      

  4.   

    我的是Microsoft .NET Framework SDK v2.0我装完的路径是
    D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
    是将这个加到Path中吗?
    还是不好使啊!
    怎么办阿?
      

  5.   

    是不是Microsoft .NET Framework SDK v2.0不支持WebRequestFactory类啊,
    查了下MSDN,没找着