2

我正在编写要在报告中引用的自定义程序集。我希望能够Report从该程序集中访问对象,这样我就可以访问报告参数和其他我可以使用自定义 RDL 代码访问的内容Report.stuff

我显然需要参考一些报告服务程序集来执行此操作,但我不知道是哪个。我试过Microsoft.ReportingServices.ProcessingCore了,因为它有一个Report具有各种属性的类,例如Parameters等等,但是当我尝试将Report对象从 RDL 自定义代码部分传递给我的类时,我收到了这个错误:

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

还有一个程序集公开了各种接口和一个抽象类Report,但它似乎没有将参数作为属性。

所以问题是,我怎么能做到这一点,我必须参考什么程序集?如果可能的话,我是否可以在Report不从 RDL 传递对象的情况下访问该对象,即这样我就可以注册我的类的一个实例,然后编写如下表达式:

=Utils.DoStuffWhileReferencingReportParameters(Fields!field.Value)

4

1 回答 1

0

在您的库中引用这两个 dll:Microsoft.ReportingServices.ProcessingCore Microsoft.ReportingServices.ProcessingObjectModel

将以下代码放入您的库中(例如)

using Microsoft.ReportingServices.ReportProcessing.ReportObjectModel;

public static string Test(Parameters item)
{

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

这是要在 RDL 文件中使用的示例表达式:

=MyNameSpace.MyStaticClass.Test(Parameters)
于 2009-12-16T22:11:33.907 回答