0

I am having an issue implementing Microsoft.Reporting.NETCore. I am working with .NET Core 3.1 and I am trying to get a SSRS report hosted on a Sharepoint server. However, when the code attempts to set the report parameters, or when it attempts to render the report, I get this error:

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.SetParameters(IEnumerable`1 parameters) at LPWebAPICore.Models.ReportGeneratorModel.GetReportBytes(String ReportPath, ReportParameter[] Params) in C:\Users\jhutchings\source\repos\LPWebAPICore\LPWebAPICore\LPWebAPICore\Models\ReportGeneratorModel.cs:line 319 at LPWebAPICore.Models.ReportGeneratorModel.GenerateReport(String ReportPath, String[] ParamNames, String[] ParamValues) in C:\Users\jhutchings\source\repos\LPWebAPICore\LPWebAPICore\LPWebAPICore\Models\ReportGeneratorModel.cs:line 279 at LPWebAPICore.Controllers.ReportGeneratorController.PrintReport(String Report, String Printer, String[] ParamName, String[] ParamValue) in C:\Users\jhutchings\source\repos\LPWebAPICore\LPWebAPICore\LPWebAPICore\Controllers\ReportGeneratorController.cs:line 73

I am building the server report as such, And I am attempting to set the parameters and render the report using this code

public ServerReport GetReportViewer(string reportPath)
{
    ServerReport report = new ServerReport
        {
            ReportServerCredentials = {
                NetworkCredentials = CredentialCache.DefaultCredentials
            },
            ReportServerUrl = new Uri(GetReportServerURL()),
            ReportPath = $"{reportPath}"
        };

    return report;
}

private byte[] GetReportBytes(string ReportPath, ReportParameter[] Params = null)
{
    ServerReport rv = GetReportViewer(ReportPath);

    if (Params == null) 
        return rv.Render("PDF");

    rv.SetParameters(Params);
    rv.Refresh();

    return rv.Render("PDF");
}
4
  • Microsoft never made a report viewer for .NET Core. What is Microsoft.Reporting.NETCore ? Apr 15, 2022 at 19:41
  • github.com/lkosson/reportviewercore
    – jhutchings
    Apr 15, 2022 at 19:46
  • You're getting an exception deep inside an open source project. Have you tried searching the Github repo for any matching issues? Or opening an issue there? Apr 15, 2022 at 19:55
  • Or indeed, as this open source, just set your debugger settings to 'break when exception is thrown' and you'll see exactly what the problem is.
    – stuartd
    Apr 15, 2022 at 21:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.