Windows Phone Developers

Saturday, October 18, 2008

The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?) [Compiler Error CS0246]

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



Error Code

using System;

using System.Collections.Generic;

using System.Linq;

XElement Inv = new XElement("Invoice",

from items in FileContent

let fields = items.Split(',')

select new XElement("Item",

new XElement("ID", fields[0]),

new XElement("Name", fields[1]),

new XElement("Price", fields[2]),

new XElement("Availability", fields[3])

Solution

Inclusion of using System.Xml.Linq directive will solve the problem

System.Xml.Linq, C# Error codes, .Net Error codes, 'XElement' in C#, 'XElement' in .NET Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

1 comment:

  1. using System.Xml.Linq;
    or you could use it like this.
    using System.Xml.Linq.XElement
    I think the first one is better.

    ReplyDelete