on 09-22-2017 12:42 AM
I have a Crystal Report file that I'm unable to even load, using the following VB.NET code:
Dim objRptDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
objRptDoc.Load("C:\path\to\my.rpt")
It throws a CrystalDecisions.Shared.CrystalReportsException
Message: Load report failed.
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
With an InnerException of type System.Runtime.InteropServices.COMException
Message: This field name is not known.
Details: errorKind
Error in File my 17320_16748_{19E5E493-1D64-4084-8E97-6395D78D94EB}.rpt:
Error in formula SubTotal Label:
'If {Invoice.ForeignSubTotal} = {Invoice.ForeignTotalAmount} Then
'
This field name is not known.
Details: errorKind
at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
Now I more or less know what the problem is... if I open the report in the Crystal Designer, do a Verify Database, and save it, it'll work fine. But I want to be able to do this automatically from my own code, rather than telling the user that they need to go run Verify Database on the report (especially since the user probably will not have access to the Crystal report designer). Normally, I'd call the ReportDocument.VerifyDatabase() method, but that assumes I already have the report loaded into the ReportDocument object. Since I can't even Load the report, I can't call VerifyDatabase.
Any advice on how I can accomplish this?
Interesting.... So it would appear your only option is to specifically test for the Inner Exception and pop up a message box "The report requires Verifying the Database in CR Designer only, the CR SDK is not capable of doing this at runtime"
I've never seen this error before on open, it does suggest the report relies heavily on that field. Because the Engine loads all objects into memory and then validates them on open your only option is to fix the report first.
I would still like the report so I can pass it by R&D to see if we can improve things on Open....
Thanks again
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of CR for VS are you using?
Later versions do not test the formula fields unless you specifically check them.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.