telerik 使用 net6 报告 Html5 时发生错误

Error happening telerik reporting Html5 with net6

提问人:sina_Islam 提问时间:8/22/2023 更新时间:8/22/2023 访问量:35

问:

我正在尝试在我的项目中手动添加 telerik 报告工具。但是低于错误。

{
    "message": "An error has occurred.",
    "exceptionMessage": "Method not found: 'Void Microsoft.AspNetCore.Mvc.JsonResult..ctor(System.Object, Newtonsoft.Json.JsonSerializerSettings)'.",
    "exceptionType": "MissingMethodException",
    "stackTrace": null
}

程序.cs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers().AddNewtonsoftJson();
builder.Services.AddControllersWithViews();


builder.Services.TryAddScoped<IReportSourceResolver, CustomReportSourceResolver>();
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "ReportingNet6",
Storage = new FileStorage(),
ReportSourceResolver = new TypeReportSourceResolver()
.AddFallbackResolver(new UriReportSourceResolver(
    System.IO.Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports"))
    .AddFallbackResolver(new CustomReportSourceResolver()))

});
var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
});

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

报表控制器

 [Route("api/reports")]
    public class ReportsController : ReportsControllerBase
    {
        public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
               : base(reportServiceConfiguration)
        {
        }
    }

The View(景观酒店)

@{
    ViewData["Title"] = "Home Page";
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<link href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.common.min.css" rel="stylesheet" id="common-css" />
<link href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.blueopal.min.css" rel="stylesheet" id="skin-css" />

<div id="reportViewer1">
    loading...
</div>

@section Scripts
{
    
    <script src="api/reports/resources/js/telerikReportViewer"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#reportViewer1").telerik_ReportViewer({
                serviceUrl: "/api/reports/",
                reportSource: {
                    report: "Product Sales.trdp",
                    parameters: {
                        CultureID: "en"
                    }
                }
            });
        });
    </script>
}
C# net-6.0 Telerik-Reporting

评论


答: 暂无答案