Unhandled exception error from Visual Studio 2010 for SECOND time the report is shown

I have a report designed with the release version of crystal reports for VS 2010.  The current status is for learning/testing how to fill in what I require in the real situation.

I have a form (ReportViewer) which has a crystal report viewer on it.  No report is attached to the viewer.
The following should pass a list with three items (each a date and two double values).  It also passes the name of the report file I want to display in the viewer.
            ReportViewer rv = new ReportViewer();
            List<MonatsrapportData> lst = new List<MonatsrapportData>();
            lst.Add(new MonatsrapportData(new DateTime(2010, 12, 12), 5, 3));
            lst.Add(new MonatsrapportData(new DateTime(2010, 12, 13), 6.8, 3));
            lst.Add(new MonatsrapportData(new DateTime(2010, 12, 14), 5, 3.9));
            rv.SetReportFile("Monatsrapport.rpt", lst);

            if (bPrint)
                rv.Print();
            else
                rv.ShowDialog();


and
    public class MonatsrapportData
    {
        public MonatsrapportData(DateTime dte, Double soll, Double effektiv)
        {
            dteDay = dte;
            dSoll = soll;
            dEffektiv = effektiv;
        }
        public DateTime dteDay;
        public Double dSoll;
        public Double dEffektiv;
    }

Open in new window


The form that wraps the report viewer has the following functionto load the report, attach the list of items and also set a (string, static) parameter which is displayed once on the report header.
        public void SetReportFile(String szRpt, List<MonatsrapportData> lst)
        {
            this.reportDoc = new ReportDocument();
            this.reportDoc.Load(szRpt);
            this.reportDoc.SetDataSource(lst);
            String s = "Hello World";
            this.reportDoc.SetParameterValue("PARAM_UserName", s);
            this.crystalReportViewer1.ReportSource = this.reportDoc;
        }

Open in new window


I execute the DEBUG build from Visual Studio and:
Everything runs, the report is displayed, the parameter has the correct value, three records appear in the detail section.  I close the app and it exits nicely.
Without making any changes I execute the debug version again from Visual Studio and I get an error when I close the app.  See picture.

Running the exe from windows explorer doesn't seem to give any problems.


What is going on with the debug version being executed from visual studio?
0005.jpg
LVL 46
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantAuthor Commented:
ps.  I get the error everytime EXCEPT the first time I display the report when I close the app.  Closing Visual Studio and restarting resets the problem so I can run the app once with error, then the second and later times I get the error.

It is annoying - I need to respond to the message box when I finish a test.
It is worrying - is there a more serious problem that could result in a crash in the real environment.
BairumCommented:
I had a similar issue before, although not specifically with crystal reports.  Try with the 'Enable unmanaged code debugging' checked under:  Project Properties ==> Debug ==> Enable Debuggers.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Hmmm.  Well that stops the messagebox (by presumably handling the exception, I'll have to check the output window) but at rather slower load and execution rates (the extra logging?).

Which is worse I ask myself - the cure or the problem ?

Thanks, and have a Merry Xmas
Mike McCrackenSenior ConsultantCommented:
DO you want to explore this further?

mlmcc
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
I'll have to study the output windows information first.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.