cancel
Showing results for 
Search instead for 
Did you mean: 

Intermittent Error Running Report

Former Member
0 Kudos

I have an intermittent issue with the WPF report Viewer.  I run a report and get the window open with the busy circle as per normal but then there is a  Invalid report file path error appearin, then a blank report is shown in the viewer.   If I run the report again everything is fine.   Can anyone help to explain why this is happening

The error being reported is.

Error Exception: SEHException

Error Message: External component has thrown an exception.

Error Stack Trace:

   at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.RemoveAfterFormatPageEventCallBack(ISCRAfterFormatPageEventCallBack formatPageEventCallBack)  

at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.RemoveAfterFormatPageEventCallBack(ISCRAfterFormatPageEventCallBack eventCallback)   

at CrystalDecisions.CrystalReports.Engine.ReportDocument.ClearCache(Boolean clearDocument)   

at CrystalDecisions.CrystalReports.Engine.ReportDocument.InternalClose(Boolean bSetupForNextReport)   

at CrystalDecisions.CrystalReports.Engine.ReportDocument.Close()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)  

at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_Database()

at ....ReportViewer.CleanUpObjectsForMemoryLeak() in ...ReportViewer.xaml.cs:line 307     at ....ReportViewer.Window_Unloaded(Object sender, RoutedEventArgs e) in..\ReportViewer.xaml.cs:line 297  

at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)   

at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)  

at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)   

at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)   

at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)   

at System.Windows.BroadcastEventHelper.BroadcastUnloadedEvent(Object root)   

at MS.Internal.LoadedOrUnloadedOperation.DoWork()  

at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()

at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()

at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)  

at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)  

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)   

at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)  

FYI the CleanUpObjectsForMemoryLeak code is listed below and all references - which should only be on window close or disposal of window

        private void CleanUpObjectsForMemoryLeak()

        {

            if (this.vwCrystalReportViewer != null)

            {

                var objRptDocViewer = (ReportDocument)this.vwCrystalReportViewer.ViewerCore.ReportSource;

                if (objRptDocViewer != null)

                {

                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in objRptDocViewer.Database.Tables)

                    {

                        table.Dispose();

                    }// Line 297

                    objRptDocViewer.Database.Dispose();

                    objRptDocViewer.Close();

                    objRptDocViewer.Dispose();

                    objRptDoc.Close();

                    objRptDoc.Dispose();

                    objRptDoc = null;

                }

                this.ParameterValues = null;

                this.PassedReport = null; //Line 307

                if (this.vwCrystalReportViewer.ViewerCore.ParameterFieldInfo != null)

                    this.vwCrystalReportViewer.ViewerCore.ParameterFieldInfo.Clear();

                if (this.vwCrystalReportViewer.ViewerCore != null)

                {

                    this.vwCrystalReportViewer.ViewerCore.Content = null;

                    this.vwCrystalReportViewer.ViewerCore.Dispose();

                }

                if (this.vwCrystalReportViewer.Owner != null)

                {

                    this.vwCrystalReportViewer.Owner = null;

                }

                this.vwCrystalReportViewer = null;

                GC.Collect();

            }

        }

private void Window_Unloaded(object sender, RoutedEventArgs e)

        {

            CleanUpObjectsForMemoryLeak();

        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

        {

           e.Cancel = true;

            CleanUpObjectsForMemoryLeak();

            this.Visibility = System.Windows.Visibility.Collapsed;

        }

~ReportViewer()

        {

            try

            {

                CleanUpObjectsForMemoryLeak();

            }

            finally { }

        }

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Couple of things I'd do differently.

1) Load the report object using the engine, not the viewer:

objRptDoc.Load = <path to the report>

2) You really do not need all that viewer clean up code (but that would just be my preference):

if (this.vwCrystalReportViewer.ViewerCore != null)

                {

                    this.vwCrystalReportViewer.ViewerCore.Content = null;

                    this.vwCrystalReportViewer.ViewerCore.Dispose();

                }

                if (this.vwCrystalReportViewer.Owner != null)

                {

                    this.vwCrystalReportViewer.Owner = null;

                }

                this.vwCrystalReportViewer = null;

                GC.Collect();

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hi Ludek,

I am Loading the report as you mentioned before.   The reason for the extreme clean up is a few versions back of crystal reports, there was a memory leak issue that was causing my application to blow in size. 

I believe this memory leak issue has been resolved. so I will implement your version of the clean up and see how things go.

Because it is intermittent I cannot tell you when I can confirm if your solution works for a couple of days.

Former Member
0 Kudos

Hi Ludek,

Unfortunately this did not fix the issue.  It still is intermittent.  It tends to happen more often when running resports one after an other,  but the sometimes on the first time you try and run a report.  

If the error happens, running the report agian causes no errors or issues.

Unfortunately there is no pattern, no common causes e.g. different reports, different database views, different times of days, different users...

former_member183750
Active Contributor
0 Kudos

Ok. Let's get back to Bhushan's question; what version of .NET and what version of CR (best to look for crpe32.dll and tell me the version of that).

What database are you using?

How are you connecting to the database (ODBC, OLE DB, etc.)?

Please provide more of a description on the following:


It tends to happen more often when running reports one after an other

What actions would I have to do to duplicate the issue? (Just keep hitting on - say a button that launches reports in the viewer? Etc.)

- Ludek

Former Member
0 Kudos

The Application is Targeting .Net 4.0

Using OLEDBSQL to connect to SQL Server Database

In the application is a Reports Menu.  Basically the user click on a report name, enters parameters and then the report is loaded into the Crystal Report viewer page.  so if the user is running a number of reports it is more likely this error occurs, but running the same report that caused the error directly afterwards, no error occurs.

Yes to duplicate the error just keep hitting the preview report button, until it occurs, which is intermittent.

Former Member
0 Kudos

crpe32.ddl version is 13.0.9.1312

former_member183750
Active Contributor
0 Kudos

What version of SQL Server Database?

What version of the SQL Server Client is installed?

- Ludek

Former Member
0 Kudos

Hi Ludek,

It happens on all the servers

Test:    SQL Server 2005,

Client : SQL Server 2008R2

Demo:  SQL Server 2012

I am using the SQLOLEDB provider, so there hasn't been an install of the SQL Client.  i.e. SQLCLXX.

former_member183750
Active Contributor
0 Kudos

Can you see if doing the following re. db clients will help?

For OLE DB use:

MS SQL 2005 - OLE DB Provider

MS SQL 2008 - SQL Native 10

MS SQL 2012 - SQL Native 11

MS SQL 2013 - SQL Native 11

For ODBC use:

MS SQL 2005 - SQL Native

MS SQL 2008 - SQL Native 10

MS SQL 2012 - SQL Native 11

MS SQL 2013 - SQL Native 11

The above clients must be used with the respective MS SQL in order to assure correct connections to CR.

- Ludek

Former Member
0 Kudos

The problem is that these clients need to be installed on every users PC,  This is a commercial application and that is not always possible that is why we are using the OLEDB driver as it is in built on windows machines. We have no control over which version of SQL Server the client is running so we cannot force a version specific client in the crystal report.

The error is not indicative of a connection issue.  It is like the viewer is having an error that is causing the window to unload and kicking off the Window_Unload event.

former_member183750
Active Contributor
0 Kudos

Hi Traci

CR, as do many other apps, absolutely requires the correct DB client. No way around that - other than creating an ADO .NET Dataset and passing that to the reports. But than it will be your responsibility to ensure that the client you connect with actually returns the correct data for the dataset. E.g.; the recommendations I posted in my previous post are from Microsoft ans we simply follow those...

- Ludek

Answers (2)

Answers (2)

Former Member
0 Kudos

Microsoft Visual Studio 2010  v10.0.40219.1 SP1Rel

Crystal Reports for .Net Framework 13.0.10

former_member188030
Active Contributor
0 Kudos

What version of Crystal Reports and Visual Studio are you using?

-Bhushan