none
COMException: Cannot find the file specified?

    Question

  • I haven't touched or ran the program i've been working on for a few months, and all of a sudden I'm getting a strange error that I cannot figure out. Perhaps you .net geniuses out there have an idea ;). Here is the error:

    System.Runtime.InteropServices.COMException was unhandled
    Message="The system cannot find the file specified.\r"
    Source="Analysis Server"
    ErrorCode=-2147467259
    StackTrace:
    at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
    at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
    at Squirrel.ReportsViewer.setStopReport(DataSet ds) in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\Squirrel\ReportsViewer.cs:line 402
    at Squirrel.ReportsViewer.gen_ReportWorkFinishedEvent(Object sender, DataSetEventArgs e) in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\Squirrel\ReportsViewer.cs:line 377
    at ReportingLib.StopReportGenerator.getStopReportDataSet() in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\ReportingLib\StopReportGenerator.cs:line 140
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()

    Here is the code where the exception is thrown:
            private void setStopReport(DataSet ds)
            {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new SetReportDelegate(setStopReport), ds);
                    }
                    else
                    {
                        this.StopReportTemplate.SetDataSource(ds);
                        this.crystalReportViewer1.ReportSource = this.StopReportTemplate;
                        this.crystalReportViewer1.RefreshReport();
                        this.crystalReportViewer1.Enabled = true;
                        this.spinningProgress.Visible = false;
                        this.generateStopReportButton.Visible = true;
                   }
            }
    The strange thing is, I generate several other reports in the same way (the reports are displayed with crystal reports), and they do not have any problems.

    If I move the line (this.StopReportTemplate.SetDataSource(ds);) outside of the invoke required code, I get a different exception as follows:

    System.Exception was unhandled
      Message="Load report failed."
      Source="CrystalDecisions.CrystalReports.Engine"
      StackTrace:
           at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
           at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
           at Squirrel.ReportsViewer.setStopReport(DataSet ds) in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\Squirrel\ReportsViewer.cs:line 401
           at Squirrel.ReportsViewer.gen_ReportWorkFinishedEvent(Object sender, DataSetEventArgs e) in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\Squirrel\ReportsViewer.cs:line 378
           at ReportingLib.StopReportGenerator.getStopReportDataSet() in C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Squirrel\ReportingLib\StopReportGenerator.cs:line 140
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    So this makes me think that perhaps the problem is with Crystal Reports?  But it doesn't make much sense, since like i said, there are several other reports generated in the same way that do not have any problems.  I think the next step is to try running the code on a different computer to eliminate the possibility of any environment problems.  Let me know if you guys have any creative ideas that could be the cause.

    Mike

    Tuesday, November 07, 2006 6:26 PM

Answers

  • So it turns out the problem was a simple one, as is the general case.  I'm not sure how I managed to bugger up the code, but I did.  I was not instantiating the StopReportTemplate :P.

    Tuesday, November 07, 2006 7:46 PM