Windows Phone Developers

Showing posts with label 'XElement' in C#. Show all posts
Showing posts with label 'XElement' in C#. Show all posts

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

The ' ' character, hexadecimal value 0x20, cannot be included in a name.

Solution : "The ' ' character, hexadecimal value 0x20, cannot be included in a name."

XML Tag should not contain any white spaces.

Change

new XElement("Total Price", fields[4])

to

new XElement("TotalPrice", fields[4])


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