【发布时间】:2016-06-09 09:05:48
【问题描述】:
我正在 Microsoft SQL Server Reporting Services 版本 11.0.2100.60 上运行的 Microsoft SQL Server Report Builder 3.0 中创建报告。
我想从我的数据集中解析存储在某些字段中的 JSON 值。下面是我的报告的预览,显示了原始 JSON 值。
我期望的表达式(虽然没有被添加)如下所示,
=Newtonsoft.Json.Linq.JArray.Parse(Fields!MyFieldName.Value).ToString()
因为我需要add custom or embedded code to my report 才能从任何表达式中调用,所以我必须add an Assembly Reference to a Report。参考:Using Custom Assemblies with Reports
所以在我的报告属性中,添加了对 Json.net (Newtonsoft.Json.4.5.6) 程序集的引用,如下所述。
程序集的路径是C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Newtonsoft.Json.4.5.6\lib\net40\Newtonsoft.Json.dll。
我还尝试将程序集添加到 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\ 和 C:\Program Files\Microsoft SQL Server\MSRS10_50.SQL2008\Reporting Services\ReportServer\bin\ 并更改对路径的引用,但无济于事。
还有提到the assembly has no dependency。
到目前为止,我刚刚添加了程序集引用,没有任何更改。但是,一旦我切换到预览我的报告,错误显示如下:
System.Web.Services.Protocols.SoapException: Error while loading code module: ‘Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’. Details: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
at Microsoft.ReportingServices.Library.ReportingService2010Impl.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
at Microsoft.ReportingServices.WebServer.ReportingService2010.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
是不是因为程序集中缺少权限属性AllowPartiallyTrustedCallers()?根据参考here,它不能解决我的问题,因为我的组件不是定制的,也找不到另一个问题here 和教程here。
我做错了什么?或者是否有任何在 SSRS 报告中解析 JSON 的工作示例?
任何帮助都会有很大帮助。
【问题讨论】:
标签: .net json reporting-services json.net ssrs-2012