2017-08-29 2 views
0

Ich verwende RDLC-Datei, um einen Bericht (ohne SQL Server Reporting Services) zu rendern und es von meinem Controller als Datei zurückzugeben. Dies ist Teil meiner MVC-Webanwendung.Diagramm im RDLC-Bericht kann nicht gerendert werden

public ActionResult Index() 
    { 
     var report = new LocalReport(); 
     report.ReportPath = Path.Combine(Server.MapPath("~/Reports"), "Report1.rdlc"); 
     var reportData = new List<MonthlyData> { 
      new MonthlyData {RecordNo=1, Tid="123456", Active=10, Inactive=1} 
     }; 
     ReportDataSource rd = new ReportDataSource("DataSet1", reportData); 
     report.DataSources.Add(rd); 
     string reportType = "PDF"; 
     string mimeType; 
     string encoding; 
     string fileNameExtension; 


     string deviceInfo = 

      "<DeviceInfo>" + 
      " <OutputFormat>" + "PDF" + "</OutputFormat>" + 
      //" <PageWidth>8.5in</PageWidth>" + 
      //" <PageHeight>11in</PageHeight>" + 
      //" <MagroupinTop>0.5in</MagroupinTop>" + 
      //" <MagroupinLeft>1in</MagroupinLeft>" + 
      //" <MagroupinRight>1in</MagroupinRight>" + 
      //" <MagroupinBottom>0.5in</MagroupinBottom>" + 
      "</DeviceInfo>"; 

     Warning[] warnings; 
     string[] streams; 
     byte[] renderedBytes; 

     renderedBytes = report.Render(
      reportType, 
      deviceInfo, 
      out mimeType, 
      out encoding, 
      out fileNameExtension, 
      out streams, 
      out warnings); 

     return File(renderedBytes, mimeType); 
    } 

Dies ist das Ergebnis:

table example in rdlc file

Alles funktioniert wie ein Charme, bis ich ein Diagramm hinzuzufügen entscheiden.

rdlc file with chart

Nun, wenn ich es mache ich zwei Ausnahmen:

Microsoft.Reporting.WebForms.LocalProcessingException: „An error occurred during local report processing.” 

DefinitionInvalidException: The definition of the report 'C:\Users\agutowski\Documents\Visual Studio 2017\Projects\rdlcMvc\rdlcMvc\Reports\Report1.rdlc' is invalid. 

und

Microsoft.Reporting.WebForms.LocalProcessingException: „An error occurred during local report processing.” 

ReportProcessingException: The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded. 

Ich habe bereits versucht, verschiedene Versionen von Microsoft.ReportViewer.Common und Microsoft.ReportViewer .WebForms.

+0

Geben Sie bitte den Inhalt der Berichtszieldatei in '\ Programme \ MSBuild \ Microsoft \ VisualStudio \ [Version] \ ReportingServices \ Microsoft.ReportingServices.targets' an. Ich denke, es sollte so eine 'ReportViewer'-Assembly enthalten:' Microsoft.ReportViewer.WebForms, Version = [Version], Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a'. –

+0

Unter 'C: \ Programme \ MSBuild \ Microsoft' gibt es keinen VisualStudio-Ordner. Ich sollte hinzufügen, dass ich nicht am Admin-Konto arbeite. – gutowskiap

+0

Haben Sie chinesische Lokalisierung für 'ReportViewer'? Ich denke, eine Problemumgehung ist möglich, indem Sie chinesische Lokalisierungs-DLLs aus dem Bereitstellungspaket entfernen (von der Veröffentlichung ausschließen). Versuchen Sie alle Pfade auszuschließen, die mit 'zh- *' im Pfad gestartet wurden. –

Antwort

0

Ich löste es durch die Verwendung Microsoft.ReportingServices.ReportViewerControl.WebForms und Microsoft.SqlServer.Types NuGet Pakete statt Microsoft.ReportViewer.Common und Microsoft.ReportViewer.WebForms.

Verwandte Themen