I'm using VS 2008 to generate a Reporting Services report definition. The problem is that whenever I try to load a report definition from a stream I get an error.

I have the following code:

```
var loaded = XDocument.Load(filePath);
LocalReport ret = new LocalReport();
using (var stream = new MemoryStream())
{
    var writer = new StreamWriter(stream);
    loaded.Save(writer);
    var ret = new LocalReport();
    ret.LoadReportDefinition(stream);

    var r= ret.GetParameters();
}

```

When the last line is executing it throws LocalProcessingException with the followinf text:

```
{"The report definition is not valid.  Details: O elemento raiz está em falta."}

```

The details translate to "root element missing".

What could be wrong?

**Edit:** The XML definition is correct. The problem lies somewhere after the loading of the definition.