ASP.NET(C#)中读取XML文件程序出错
我点调试的时候提示说:
编译器错误信息: CS0234: 类型或命名空间名称“Global”在类或命名空间“System.Web.UI.WebControls.Xml”中不存在(是否缺少程序集引用?)
源错误:
行 26:
行 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 28: public class Global_asax : Xml.Global {
行 29:
行 30: private static bool __initialized = false;
源文件: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\xml\04e60542\bc5fb0cd\gruqn1cn.0.cs 行: 28
程序的代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Text;
namespace Xml1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
XmlTextWriter xw=new XmlTextWriter(Server.MapPath("book.xml"),Encoding.UTF8);
try
{
xw.WriteStartDocument();
xw.WriteStartElement("Book");
xw.WriteElementString("TITLE","C# Developer's Guide");
xw.WriteEndDocument();
Response.Write("your file has been written");
}
catch(Exception ex)
{
Response.Write("Exception:"+ex.Message);
}
finally
{
xw.Flush();
xw.Close();
}
}
}
}
我是按照一本书上的例子来写的,结果就是不行。郁闷,哪位懂这个的指点下。先谢谢了!
用的是v1.1.4322库,工具是vs.net(2002)