lkosson / reportviewercore

Recompilation of Microsoft.ReportViewer for .NET Core 3.1+
427 stars 123 forks source link

error generating report .net core 7 #121

Closed AKHALEFA closed 1 year ago

AKHALEFA commented 1 year ago

I'm getting the error below when generating the report, using this code. List[ReportParameter] parameters =< reportParameters>; string? serverPath = "http://server_url/ReportServer"; string? reportPath = $"/rootFolder/abc_report"; var report = new Microsoft.Reporting.NETCore.ServerReport() { ReportServerCredentials = { NetworkCredentials = new NetworkCredential(){ "X","Y","Z"} }, ReportServerUrl = new Uri($"{serverPath}"), ReportPath = $"{reportPath}" }; if (parameters == null) report.Render("PDF"); report.SetParameters(parameters); report.Refresh(); byte[] pdf = report.Render("PDF"); return pdf;


System.MethodAccessException: Attempt by method 'Microsoft.Reporting.NETCore.SoapReportExecutionService.get_Service()' to access method 'Microsoft.ReportingServices.Diagnostics.MonitoredScope.New(System.String)' failed. at Microsoft.Reporting.NETCore.SoapReportExecutionService.get_Service() at Microsoft.Reporting.NETCore.SoapReportExecutionService.SetExecutionId(String executionId) at Microsoft.Reporting.NETCore.ServerReport.ApplyExecutionIdToService(IReportExecutionService service) at Microsoft.Reporting.NETCore.ServerReport.get_Service() at Microsoft.Reporting.NETCore.ServerReport.EnsureExecutionSession() at Microsoft.Reporting.NETCore.ServerReport.Render(String format, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings) at Microsoft.Reporting.NETCore.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings) at Microsoft.Reporting.NETCore.Report.Render(String format, String deviceInfo) at Microsoft.Reporting.NETCore.Report.Render(String format) at Program.<>c.<<

$>b0_6>d.MoveNext() in C:\Users\aawadalla.c\source\repos\KSU.ReportingAPI\Program.cs:line 142 --- End of stack trace from previous location --- at Microsoft.AspNetCore.Http.RequestDelegateFactory.g__ExecuteAwaited|111_0[T](Task`1 task, HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

lkosson commented 1 year ago

I can't reproduce the behavior. It looks like your copy of Microsoft.ReportViewer.NETCore.dll references mismatched version of Microsoft.ReportViewer.Common.dll. Please check your NuGet/DLL references and if error persists, try reproducing the behavior using the ReportViewerCore.Sample.WinFormsServer sample project from this repository.

AKHALEFA commented 1 year ago

Thanks, it seems that Microsoft.ReportViewer.NETCore.dll V15.1.17 do not work with Microsoft.ReportViewer.Common.dll V150.1537.0; I used V140.1404.0 instead.