exe directory location getting added to rdlc report name

时间:2015-12-14 17:56:15

标签: vb.net visual-studio-2013 rdlc reportviewer

I'm trying to deploy my Windows Form application and the report viewer is unable to find my rdlc reports. When I run the report I get an error and I've copied the top line here:

Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> System.ApplicationException: The report definition for report 'LWMIrptWeeklyDonations' has not been specified ---> System.IO.FileNotFoundException: Could not find file 'C:\Users\LWMI\LWMIrptWeeklyDonations.rdlc'.

My report name is in fact rptWeeklyDonations, however LWMI is getting added to the front, which happens to be the directory that my exe is located in. It appears the report is being looked for, but the name doesn't match so it can't find it. How can I keep the directory location from being added to the name?

Code that I'm using:

'ReportViewer1.LocalReport.ReportPath = Replace(Directory.GetCurrentDirectory, "bin\Debug", "") & strRPTReportName & ".rdlc"

Changed to:

ReportViewer1.LocalReport.ReportPath = Environment.CurrentDirectory & "\" & strRPTReportName & ".rdlc"

The first line is how the program was originally written. My mentor then suggested a workaround he found which was to add the second line and comment out the first. Then put the .exe and the RDLC files in a folder to run from there. It works but it's not ideal because those files could be deleted by a user.

0 个答案:

没有答案