【问题标题】:SSRS Report Builder How to parse JSON from Dataset field?SSRS Report Builder 如何从数据集字段解析 JSON?
【发布时间】: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


    【解决方案1】:

    我可能在这里过度简化了,但程序集 ddl 是位于客户端上还是报表服务器上,或者两者兼而有之,正如我过去发现的那样,除非我在客户端和服务器上都有程序集,否则我会收到奇怪的错误消息。同样在将 ddl 添加到 bin 目录后,我的如下(C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\bin)需要重新声明报表服务器服务以获取程序集

    【讨论】:

    • 有人解决了这个问题吗?我遇到过类似的问题
    【解决方案2】:

    错误表明它可以找到Version 4.5.0.0;您展示的图片是针对Version 4.5.6 的,除非明确指定,否则它们不可互换。

    所以你有两个选择:

    1. 删除当前对 NewtonSoft.Json.dll 的引用;从该 DLL 的所有版本中清除您的文件夹并重新开始。

    2. 在机器级别指定 assemblyBinding - machine.config。这是您的操作方法< assemblyBinding > Element for < runtime >。专注于第一个例子。 bindingRedirect 就是您要找的。​​p>

    【讨论】:

      猜你喜欢
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2020-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      相关资源
      最近更新 更多