on 11-27-2008 1:19 PM
We recently bought u201CCrystal Reports 2008u201D and converted our project to this version instead of u201CCrystal reports for Visual Studiou201D. The reports are working fine but after a while we get the error displayed below in all our reports.
We have installed the redist of crystal reports 2008 sp1 on the server.
There seems to be no common factor in this, the error is thrown at random times, but once it's thrown, it keeps occuring. At this time the only way to resolve this problem for us is to reset the IIS ('issreset'). However after a certain time the exception is thrown again.
Another strange thing is the error itself, we are using a dataset as datasource for our reports. So we donu2019t even connect to a databaseu2026
This is a serious problem for us, so if you could help us to find a solution for this then that would be most appreciated.
CrystalDecisions.CrystalReports.Engine.LogOnException: Database logon failed. ---> System.Runtime.InteropServices.COMException (0x8004100F): Database logon failed.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
--- End of inner exception stack trace ---
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToHttpResponse(ExportOptions options, HttpResponse response, Boolean asAttachment, String attachmentName)
Hi Stefan,
The error is usually due to the report object has failed to load. Make sure you trap all errors.
Does this happen on your development PC or just the production server ( or test production server )?
Make sure once you are finished with the report objects to close and dispose of them as well as using the GC.Collect to force Windows to clean up it's memory marked for release.
Thank you
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have precisely the same problem as has been described by Stefan Van den Ende. I am running a crystal report and on my dev machine it works without fail and on my test machine it generates the following call trace:
EXCEPTION:
LogOnException
EXCEPTION MESSAGE:
Database logon failed.
STACK TRACE:
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.ReportSource.EromReportSourceBase.HandleException(Exception exception)
at CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.GetLastPageNumber(ReportPageRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.HTMLExporter..ctor(FormatEngine formatEngine, ExportRequestContext requestContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export()
at Report.ExportToHTML()
I am hoping that since the previous case was generated last year that there is more light that might be shed on why I am having the problem now. I opened crystal and did a verify database and there are no problems. I use datasets and never connect directly to database. Also, if I run the viewer outside of ASP.NET I can generate the report just fine so it appears to be something with ASP.NET. Please help and thanks.
-Marcus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ludek,
Thank you for your reaction, I think this will solve most of the problems for the error u201CLogOnExceptionu201D because I am aware that the dataset must be exactly equal with the dataset used to develop the report.
Unfortunately that is not helping me in this case, because I have the latest updates from Crystal Reports and the report does work on the server, but after a day (sometimes less) the same report with the same data will throw this error.
I believe it could be a memory leak or something similar, despite closing, disposing the report and calling the garbage collector from visual studio. After an u201Ciisresetu201D it starts working again, but only for a limited period of time before the error occurs again.
We are thinking of rolling back to u201CCrystal Reports For VS 2008u201D because with this version we donu2019t have any of these problems. The only problem with this version is that it doesnu2019t support loading dynamic images in the report.
Stefan
OK. Understood. Tough nut to crack with the behavior you describe. I'm not sure it's a memory leak as I think we'd have heard about it by now. I mean, the error is reported often enough, but it's usually a database, or code issue or some other "vanilla" stuff.
I wonder, since you are using datasets, are you also handling these objects correctly? E.g.; any object that supports IDisposable interface may need to be set to nothing (close, dispose) once in a while - particularly if the object (dataset) is being reused. Also, have a look at how many database licenses are used up when the error occurs. (I understand this used to work with a previous version of CR, but perhaps other things changed as well (environmental, database, loads, db client, etc., etc.))
Another thing. Make sure you are using latest runtime from SP1 for CR 2008. MSM is here:
https://smpdl.sap-ag.de/~sapidp/012002523100011715292008E/cr121_mm.zip
MSI is here:
https://smpdl.sap-ag.de/~sapidp/012002523100011722132008E/cr121_redist_install.zip
Ludek
Ludek,
Thank you for your fast response.
The function Iu2019m using this moment, as you can see i do everything in my power 2 release the report.
public static void ExportCrystalReports(string reportFile, string exportName, DataSet ds, List<CrystalReportParameter> parameters)
{
ReportDocument crDocument = new ReportDocument();
byte[] fileContent = null;
try
{
crDocument.Load(reportFile);
foreach (Table table in crDocument.Database.Tables)
table.SetDataSource(ds.Tables[table.Name]);
//crDocument.SetDataSource(ds.Tables[0]);
ParameterDiscreteValue pdv;
foreach (CrystalReportParameter parameter in parameters)
{
pdv = new ParameterDiscreteValue();
pdv.Value = parameter.Waarde;
crDocument.SetParameterValue(parameter.Naam, pdv);
}
pdv = null;
fileContent = ((MemoryStream)crDocument.ExportToStream(ExportFormatType.PortableDocFormat)).ToArray();
//crDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, exportName);
}
finally
{
crDocument.Close();
crDocument.Dispose();
crDocument = null;
ds.Dispose();
GC.Collect();
}
try
{
ByteToResponse(exportName, fileContent);
}
finally
{
fileContent = null;
}
}
public static void ByteToResponse(string exportName, byte[] fileContent)
{
if (fileContent != null)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + exportName);
HttpContext.Current.Response.BinaryWrite(fileContent);
HttpContext.Current.Response.End();
}
}
Stefan
Right, but what about the dataset? Can you do ds.close, ds.dispose on it somewhere? I have seen issues where the ds is create a bunch of reports run against it. Then the dataset is populated with new data, bunch of reports run against it and so on. But if the dataset is not closed and disposed, it can cause the issue also. And any other objects hitting the database?
Ludek
Sorry about that. I must be going blind in my old age. That is two threads this week where I missed obvious code...
We may be at a point where Don suggested the phone support idea. Code wise, things look good. Checking the DB licenses and connections at the time of the error may still be a good idea. But other than that...
This is the link for phone support:
Ludek
Unless the issue you are getting is absolutely identical to the one described in this thread (error, message, code, versions of CR , .NET, OS, database, etc., etc.) I'd recommend creating a new thread with as much detail as possible in it.
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Don,
Iu2019m familiar with Process Explorer but this in this case itu2019s not helping because itu2019s is running on a web server (ASP.Net) as you can read in my posts above. So itu2019s a little difficult to watch my exe (aspnet_wp.exe).
A different database driver is not possible because I donu2019t have direct access to the database, the application is working with a dataset as datasource as you can read in previously posts:
u201CAnother strange thing is the error itself, we are using a dataset as datasource for our reports. So we donu2019t even connect to a databaseu2026u201D
All the reports have the option u201CNo Default printeru201D selected but this is not preventing crystal reports to fail.
And the last option, in all previously versions of crystal reports, the code works without any problem. As I said on the same server applications with CR for VS 2008 are running perfectly. We only got the problem with CR 2008, in the beginning itu2019s running like it suppose to work but after a while itu2019s failing with the error that Iu2019ve posted in the beginning. And after a iis reset, itu2019s working again for a random short (avg 4 hours) time.
Iu2019ve even tried sample code from your website on a very basic report using a dataset as datasource and the same problem occurred.
So I donu2019t think itu2019s in our software. Do you have another suggestion that can help me, because I have the feeling we arenu2019t making any progress on the problem.
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
Anything more would be to complex to handle in this forum. I suggest you purchase a case on line and get a dedicated Engineer to work with you. You can then pass log files and other test applications back and forth.
You may want to use a tool called Win Debug Diag from Microsoft to capture the exception, it may tell you what API is causing the issue. The dump file can be analysed here against the source code which may tell use which API is causing the issue also. Mention my name to the case owner, I have access to the source and can analyse the dump file.
Thank you
Don
Unfortunately your solution did not resolve the issue, after a certain time the error as described above still occurs.
Do you know if there is another possible solution for us?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don,
Iu2019ve tried everything but it still isnu2019t working. I installed SP1 re-distribute the runtime on the server but that didnu2019t solve anything. In the application itself I call the garbage collector and dispose the report without success. The application is moved to a whole new server but Crystal Reports still keeps failing after a while.
Crystal Reports for visual studio 2008 is working without any problem on the same server for other applications, but we have purchased Crystal reports 2008 because itu2019s easy to load dynamic images.
I think we have done everything right and there is a bug in Crystal Reports, but this conclusion is not helping me to complete the project.
Our customers are not amused, as am I, do you have another suggestion to solve our problem? In the worst case another version of Crystal Reports or something?
Stefan
Hi Stefan,
There are various tools out there that may help. Use Process explorer from www.sysinternal.com (microsoft) and watch your exe. Other options woul dbe to use Microsofts Debug Diagnostic tool to create DUMP files. You won't be able to get into CR runtime but it may point you to what dll is causing the exception.
Next is to try a different database driver, ODBC, OLE DB or if we have a native driver try that. Logon exception is usually due to trying to connect a report that failed to open or there are simply no system resources left to make the connection. Add more logging to your app also.
One final test is to open a few of your reports and check on No Default printer. There are problems in printer drivers not allocating or releasing memory properly and these show up as memory leaks in CR. We make a copy of the DEVMODE structure so changes can be made without affecting the default printer. If the driver has issues they are passed onto CR.
Last option is to purchase a case on line and an Engineer can assist you directly, pass smaple apps and code and any logs generated etc.
Thank you
Don
It happens on the production server, we don't have any problems with the test server. I used the following code:
Dim rptDocument As ReportDocument = new ReportDocument()
rptDocument.Load("Report.rpt")
Dim exportOpts As ExportOptions = new ExportOptions()
Dim pdfOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
exportOpts.ExportFormatOptions = pdfOpts
rptDocument.ExportToHttpResponse(exportOpts, Response, False, "")
I changed it to
Dim rptDocument As ReportDocument = new ReportDocument()
rptDocument.Load("Report.rpt")
Dim exportOpts As ExportOptions = new ExportOptions()
Dim pdfOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
exportOpts.ExportFormatOptions = pdfOpts
Try
rptDocument.ExportToHttpResponse(exportOpts, Response, False, "")
Finally
rptDocument.Dispose()
GC.Collect()
End Try
I will upload it today and report the result.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.