title: XtraReport : An object assigned to the DataSource property cannot be used
body: <p>I have a C# application that use reports stored in a database, and for a particular report, that use a XPObject as datasource (<em>CptOperation class, the code is below</em>), I have this error message when trying to print or preview :</p>
  
  <blockquote>
    <p>An object assigned to the DataSource property cannot be used as a
    report's datasource, because it does not implement any of supported
    interfaces. For more information, refer to
    <a href="http://help.devexpress.com/#XtraReports/CustomDocument1179" rel="nofollow">http://help.devexpress.com/#XtraReports/CustomDocument1179</a></p>
  </blockquote>
  
  <p>Here is the code I use to print my report.</p>
  
  <pre><code>public static void PrintReport(string reportCode, object dataSource, string printerName)
  {
      using (var uow = new UnitOfWork { ConnectionString = Content.GlobalInfo.ServerConnectionString })
      {
          var report = uow.FindObject&lt;Content.Report&gt;(new BinaryOperator("Code", reportCode));
          if (report == null)
          {
              XtraMessageBox.Show(String.Format("The report {0} is not found", reportCode),
                  Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              return;
          }
  
          var xtraReport = getXtraReportFromReport(report);
          xtraReport.DataSource = dataSource;
  
          if (!String.IsNullOrEmpty(printerName))
              xtraReport.Print(printerName);
          else
              xtraReport.Print();
      }
  }
  
  private static XtraReport getXtraReportFromReport(Content.Report report)
  {
      XtraReport xtraReport;
      using (var writer = new StreamWriter(new MemoryStream()))
      {
          writer.Write(report.Content);
          writer.Flush();
          xtraReport = XtraReport.FromStream(writer.BaseStream, true);
      }
      return xtraReport;
  }
  </code></pre>
  
  <p>Here is my object persistance class "CptOperation" :</p>
  
  <pre><code>private CptTypeOperation cptTypeOperation;
  public CptTypeOperation CptTypeOperation
  {
      get { return cptTypeOperation; }
      set { SetPropertyValue&lt;CptTypeOperation&gt;("CptTypeOperation", ref cptTypeOperation, value); }
  }
  
  private int numero;
  public int Numero
  {
      get { return numero; }
      set { SetPropertyValue&lt;int&gt;("Numero", ref numero, value); }
  }
  
  private CptSession cptSession;
  [Association("CptSession-CptOperation")]
  public CptSession CptSession
  {
      get { return cptSession; }
      set { SetPropertyValue&lt;CptSession&gt;("CptSession", ref cptSession, value); }
  }
  
  [Association("CptOperation-Piece")]
  public XPCollection&lt;Piece&gt; Pieces
  {
      get { return GetCollection&lt;Piece&gt;("Pieces"); }
  }
  
  [Association("CptOperation-Transact")]
  public XPCollection&lt;Transact&gt; Transacts
  {
      get { return GetCollection&lt;Transact&gt;("Transacts"); }
  }
  </code></pre>