ReportViewer.LocalReport.SetParameters() fails after a report has been exported to a file location that no longer exists (media removed, invalid path, etc.). Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report 'Main Report' is invalid. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.Runtime.InteropServices.ExternalException: Cannot execute a program. The command being executed was "c:\WINDOWS\Microsoft.NET \Framework\v2.0.50727\vbc.exe" /noconfig @"C:\Documents and Settings \...\Temp\_c0gtdjg.cmdline". To demonstrate you will need a win forms app with a main form and a second form with the ReportViewer control. A button on the main form launches the report form and populates the control with data and sets report parameters. Run the app, navigate to the report form and display the report. Now Export to PDF to some sort of removable media. Close the report form but not the application. Remove the media. Navigate back to the report form. The above exception occurs when attempting to SetParameters(). I can catch the exception, but I can not figure out a way to cleanly recover. The only recovery is to exit the application and go back in. It will attempt to access the non-existent media, but it doesn't throw an exception.
I have found a workaround: try { this.reportViewer.LocalReport.SetParameters(reportParameters); } catch { // Set directory to any valid path. // The actual path doesn't seem to influence the Export dialog: System.IO.Directory.SetCurrentDirectory(anyValidDirectoryPath); // Try again: this.reportViewer.LocalReport.SetParameters(reportParameters); } Hope this helps prevent someone from blowing an entire afternoon on a
Don't see what you're looking for? Try a search.
|