Accepted answer

Are you using .NET 3.5 by any chance? XDocument.Load(Stream) apparently only arrived in .NET 4.

You might want to use the overload which takes an XmlReader (which is supported in 3.5).

EDIT: Sample code:

static XDocument LoadFromStream(Stream stream)
    using (XmlReader reader = XmlReader.Create(stream))
        return XDocument.Load(reader);    


The XDocument.Load(Stream) method is new in .NET 4. For earlier versions of the framework, you need to read the stream first and pass it in as a string:

public static void readXMLOutput(Stream stream){
    string streamContents;
    using(var sr = new StreamReader(stream)){
        streamContents = sr.ReadToEnd();

    var document = XDocument.Parse(streamContents);

Related Query

More Query from same tag