You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Telerik报表R1 2017部署后预览报Value cannot be null错误

Telerik R1 2017报表REST服务预览报错:Value cannot be null. Parameter name: source

问题详情

在C#项目中使用Telerik R1 2017版本的报表REST服务,参数及数据库数据均能正常加载,但点击预览时出现错误:Value cannot be null. Parameter name: source。通过分析Telerik DLL可知错误源于参数值列表为空,但网络日志显示所有参数已传递至REST API。

请求负载

{"report":"Activity/Registered Users Report.trdp/VisionReport","parameterValues":{"CPR":"353464654","EMAIL":"","MOBILE":"","FromDate":"2023-12-31T00:00:00.000Z","ToDate":"2024-01-01T00:00:00.000Z","ChannelId":["006","002","005"]}}

请求URL

https://localhost:44302/api/reports/clients/aaf42228070/instances

环境差异

  • 本地环境运行正常
  • 部署到服务器后仅浏览器加载时出错
  • 服务器上的Telerik Designer运行该报表无问题

完整错误信息

{
  "message": "An error has occurred.",
  "exceptionMessage": "Value cannot be null.\r\nParameter name: source",
  "exceptionType": "System.ArgumentNullException",
  "stackTrace": "   at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)\r\n   at Telerik.Reporting.Services.Engine.PersistableCollection`1.GetEnumerator()\r\n   at Telerik.Reporting.Services.Engine.KeyItemPersistableCollection`2.ResolveItem(K referredInstanceKey, Boolean& newItem)\r\n   at Telerik.Reporting.Services.Engine.ReportEngine.CreateReportInstance(String clientID, String report, Dictionary`2 parameterValues)\r\n   at Telerik.Reporting.Services.WebApi.ReportsControllerBase.CreateInstance(String clientID, ClientReportSource reportSource)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__3(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()"
}

解决方案

从错误栈跟踪来看,问题出在Telerik服务端解析参数时,某个内部集合source为空。结合环境差异和版本特性,可尝试以下步骤:

  • 检查报表参数配置:确认ChannelId参数在报表中的类型为Array,且“允许空值”的配置与本地一致。服务器设计器正常不代表REST服务的参数解析逻辑完全匹配。
  • 调整数组参数传递格式:Telerik R1 2017的REST服务对数组参数的序列化存在兼容性问题,尝试将ChannelId的数组格式["006","002","005"]改为逗号分隔的字符串"006,002,005",同时在报表中设置参数的MultiValue属性为true,确保能正确解析该格式。
  • 校验JSON序列化配置:确保服务端Web API使用的Newtonsoft.Json版本与本地一致(Telerik R1 2017通常依赖Newtonsoft.Json 9.0.1或兼容版本),检查WebApiConfig中的序列化设置是否启用了数组的正确处理:
    config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
    {
        NullValueHandling = NullValueHandling.Ignore,
        Formatting = Formatting.Indented
    };
    
  • 处理空字符串参数:将请求中的空字符串参数EMAIL、MOBILE改为null,避免Telerik服务端解析空字符串时触发内部集合为空的异常。
  • 升级Telerik补丁:R1 2017存在已知的REST服务参数解析bug,若允许升级,安装R1 2017 SP1补丁可修复部分参数处理问题。

内容的提问来源于stack exchange,提问作者user3094279

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 14:39:58