views:

715

answers:

1

I'm writting a custom assembly to be referenced in a report. I'd like to be able to access the Report object from that assembly, so that I could then access the report parameters and other stuff that I can access in custom RDL code by using Report.stuff.

I obviously need to reference some reporting services assembly to do this, yet I can't figure out which. I tried Microsoft.ReportingServices.ProcessingCore, since it has a class Report with various properties like Parameters etc., but when I tried to pass the Report object from the RDL custom code section to my class, I got this error:

Unable to cast object of type 'ReportExprHostImpl' to type 'Microsoft.ReportingServices.ReportRendering.Report'.

There's also an assembly which exposes various interfaces and an abstract class Report, but it doesn't seem to have the parameters as a property.

So the question is, how could I achieve this, what assembly do I have to reference ? And if possible, can I access the Report object without passing it from the RDL, i.e. so that I could just register an instance of my class and later write expressions like:

=Utils.DoStuffWhileReferencingReportParameters(Fields!field.Value)

A: 

Reference these two dlls in your library: Microsoft.ReportingServices.ProcessingCore Microsoft.ReportingServices.ProcessingObjectModel

Put the following code in your library (as an example)

using Microsoft.ReportingServices.ReportProcessing.ReportObjectModel;

    public static string Test(Parameters item)
    {

        return item ["my_parameter_name"].Value.ToString();
    }

Here’s an example expression to use in your RDL file; =MyNameSpace.MyStaticClass.Test(Parameters)

Steve
I don't think referencing ProcessingCore is necessary and I've found out that referencing the object model does not solve the exact problem I had, in fact I found out it's basically impossible to reference the parameters in the dll without passing them from the RDL somehow - that's what I ended up doing, I made the constructor accept the Parameters collection. Anyways, for your effort - I accept your answer :)
Saulius