ASP.NET(C#)中读取XML文件程序出错

Matthew 2004-12-11 11:23:15
我点调试的时候提示说:

编译器错误信息: 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)
...全文
108 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Matthew 2004-12-12
  • 打赏
  • 举报
回复
谢谢,问题解决!
saucer 2004-12-11
  • 打赏
  • 举报
回复
别给你的项目或命名空间取名为Xml,换成别的名字

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧