Daniel Manfrini
Daniel Manfrini

Reputation: 41

ReportViewer error when dynamically setting rdlc file on Azure Cloud Services

OK, this should be pretty easy but, I cannot figure out whats going on. I have an ASP.NET web application that runs in an Azure Cloud Services and in one of the aspx pages there is a ReportViewer. At this page´s codebehind I dynamically add ReportViewer´s design .rdlc file with the line:

ReportViewer1.LocalReport.ReportPath = Server.MapPath("reports/myReportFile.rdlc");

When I run the report on localhost, everything works fine, but when I publish to Azure Cloud Services I get the following error:

Could not find a part of the path 'F:\sitesroot\0\reports\myReportFile.rdlc'. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\sitesroot\0\reports\myReportFile.rdlc'.

That should be obvious, right? The file path is invalid or the .rdlc file is not there. I tried changing the .rdlc file properties on Visual Studio, setting "Copy to Output Directory" = "Copy always", and again I got exactly the same error.

Observations: I´m publishing using Azure Tools/Package (.cscfg + .cspkg) and uploading them through Azure Management Portal.

Any ideas on what I should do next?

Upvotes: 2

Views: 4685

Answers (2)

Rizwan Hassan
Rizwan Hassan

Reputation: 1

rdlc not found in report viewer in windows form application Set "Copy to Output Directory" to "Copy always" or "Copy if newer" then use "bin\Report1.rdlc" in in LocalReport.ReportPath Property

Upvotes: 0

Daniel Manfrini
Daniel Manfrini

Reputation: 41

After a couple hours researching I found a solution here: https://social.msdn.microsoft.com/Forums/azure/en-US/f1eb4502-0549-4130-a0d9-9f9abf66c6ab/how-to-run-reportviewer-in-azure-?forum=windowsazuredevelopment

For rdlc file, by default, the "Build Action" is "Embedded Resource" causing that the file will be embedded in the DLL. Setting "Copy to Output Directory" to "Copy always" causes the Report1.rdlc file will be copied to the bin folder. After knowing this, there are two options to resolve the issue:

  1. Set the "Build Action" as "Content" then use "Report1.rdlc" in LocalReport.ReportPath Property.

  2. Set "Copy to Output Directory" to "Copy always" or "Copy if newer" then use "bin\Report1.rdlc" in in LocalReport.ReportPath Property.

Wenchao Zeng

Suggestion #1 solved the problem.

Upvotes: 2

Related Questions