This blog is a personal outlet to share some things I encounter during my coding adventures and would like to share with the world, so that others (hopefully) can profit by it.

This blog does not express in any way the views and opinions of the companies I work for!

Happy reading and of course leave your comments where you see fit!

vrijdag 2 maart 2007

Business objects in Reports VS 2005 SP1

As I laid out in post Visual Studio 2005.NET SP 1, there are some problems using business objects inside reporting services reports. The problem in short is that the businessclasses you have defined are not visible inside the “Data Sources” pane of the report editor. I also suggested a possible solution, which is very cumbersome to perform. Here is another possibility to work around this problem.


Lately, I have been doing some additional testing with the report tool and found out two things:

  • Business objects do not show automatically anymore in the Data Sources pane
  • You can add Data Sources to the Data Sources pane based on your business objects
  • You can only add Data Sources from your business objects if it is defined in the same assembly
  • The Data Sources pane is buggy when no Data Sources are defined within you assembly of Web application: f.e. with the pane empty you can bring up the “Remove object” from the popup menu, under these circumstances also the line “There are no data sources to show for the selectd project.” is not visible!


I have found a workaround which is not as clean as I would like but is workable until a fix is released:

  • Define the reports in the assembly where the business objects are defined, using the Add Data Source function from the Data Sources pane. I don’t like this part, because it mixes in some of the presentation into the business layer, but I guess I can live with it for now…
  • Reports by default are embedded in their assembly as resources, this makes it possible to load the resource from the calling Web application:


    LocalReport report = new LocalReport();
    if (WebConfigurationManager.AppSettings(“LocalReportPath”) == null)
    {
    Stream rs = typeof(OrdersClass).Assembly.GetManifestResourceStream(“Dnote.MyApp.Model.Reports.TestReport1.rdlc”);
    report.LoadReportDefinition(rs);
    }
    else
    report.ReportPath = Server.MapPath(WebConfigurationManager.AppSettings(“LocalReportPath”).ToString());



You can of course decide to always load the reports from the rdlc file, but personally I don’t like to move around files before a release, because I’m sure I would forget to do that one day. Also, it would not be compatible with the Publish Web Site function of VS.NET 2005.

Geen opmerkingen:

Een reactie posten

Labels