0
我正在使用RDLC文件呈现报表(无SQL Server Reporting Services)并将其从我的控制器作为文件返回。这是我的MVC Web应用程序的一部分。无法在RDLC报表中呈现图表
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);
}
这是结果:
一切就像一个魅力,直到我决定添加一个图表。
现在,当我呈现它,我得到两个例外:
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.
和
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.
我已经尝试过不同的版本Microsoft.ReportViewer.Common和Microsoft.ReportViewer的.WebForms。
请包含位于'\ Program Files \ MSBuild \ Microsoft \ VisualStudio \ [版本] \ ReportingServices \ Microsoft.ReportingServices.targets'中的报告目标文件的内容。我认为它应该包含像这样的ReportViewer程序集:Microsoft.ReportViewer.WebForms Version = [version],Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。 –
在'C:\ Program Files \ MSBuild \ Microsoft'下没有VisualStudio文件夹。我应该补充一点,我没有使用管理员帐户。 – gutowskiap
你有使用中文本地化的'ReportViewer'吗?我认为可以通过从部署包中删除中文本地化DLL(从发布中排除)来解决这个问题。尝试排除路径中以'zh- *'开头的所有路径。 –