xmlwriter not recognised

Hi
I'm looking at an example use of the xmlwriter in .net 2.0.
When I compile the code shown, I get errors like

The type or namespace name 'XmlWriterSettings' could not be found (are you missing a using directive or an assembly reference?)      

Why is this happening please? Do I need to add a reference to the project?

Thanks
<%@ WebHandler Language="C#" Class="Handler" %>
 
using System;
using System.Web;
 
public class Handler : IHttpHandler {
 
    public void ProcessRequest(HttpContext context)
    {
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
 
        context.Response.ContentType = "text/xml";
 
        using (XmlWriter writer = XmlWriter.Create(context.Response.OutputStream, settings))
        {
            writer.WriteStartElement("slides");
            writer.WriteStartElement("slide");
            writer.WriteAttributeString("imageUrl", "foo.jpg");
            writer.WriteAttributeString("thumbnailUrl", "foo_thumb.jpg");
            writer.WriteAttributeString("caption", "this is a test");
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
 
}

Open in new window

LVL 9
peterdunganAsked:
Who is Participating?
 
peterdunganConnect With a Mentor Author Commented:
It works after adding using system.xml to the references.

0
 
Jaime OlivaresSoftware ArchitectCommented:
You will need:

using System.Xml;

at the beginning of your source code file, and also check the project References, as peter stated.
0
 
Jaime OlivaresSoftware ArchitectCommented:
to be more specific, go to Menu -> Project -> Add Reference... -> .net tab
Check if System.Xml.dll reference is checked.
0
 
peterdunganAuthor Commented:
Yes thanks I realised that and posted the reply above.
0
 
Jaime OlivaresSoftware ArchitectCommented:
sorry, not noticed, that you was the question's author.
0
All Courses

From novice to tech pro — start learning today.