on 02-03-2015 5:30 AM
Hi,
I'm running a C# .NET application on Windows Server 2012 R2 with .NET Framework 4.5. This application depends on the Crystal Reports runtime engine for .NET Framework 4.
After setting up my report (initialising object, loading .rpt file, setting database connection details, passing parameters), I am then exporting this report to a stream, then copying to a memory stream.
MemoryStream memoryStream = new MemoryStream();
Stream exportStream = crystalReport.ExportToStream(ExportFormatType.PortableDocFormat);
exportStream.CopyTo(memoryStream);
This process hangs for a minute or so before producing this exception/stack trace
System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the path specified.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
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.ExportToStream(ExportFormatType formatType)
I've checked the permission of the .rpt file it uses and it has permission to read these files for the user the process is running as.
I've also confirmed that the user has permission to read/write to "%temp%" which resolves to "\AppData\Local\Temp\1" for that user. As the code is executed it writes 4 files to this location, before cleaning up 3 of them as the exception is thrown. One empty file remains.
I've reinstalled/repaired both the 32 and 64 bit editions of the runtime, and have also installed the Microsoft Visual C++ 2005 redistributables including the security updates. I did not receive any DLL registration errors while installing on this server (though have in previous deployments which were missing the dependencies).
I'm at a loss as to where to look into next. Any help would be appreciated.
Thanks,
Brent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
After reviewing that thread I can see there is a workaround that may/may not impact performance, however this is the original approach I'm using and still experiencing the error.
As an alternative approach I've avoiding exporting to a stream all together and instead writing the file directly to the disk.
crystalReport.ExportToDisk(ExportFormatType.PortableDocFormat, documentFilePath);
However I still receive the same exception
System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the path specified.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName)
This is only occurring on a production server. If I run this locally with the same version of the Crystal Reports runtime engine I do not experience this error (in both writing to a stream and a file).
Thanks,
Brent
Hi,
The cause of the issue turned out to be improperly setting the database connection details in the report. Originally I was only doing this
crystalReport.SetDatabaseLogon(
Program.SystemSettings.DatabaseUsername,
Program.SystemSettings.DatabasePassword,
Program.SystemSettings.DatabaseServer,
Program.SystemSettings.DatabaseDomainDatabase);
I've since added this section to also apply to each table
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.UserID = Program.SystemSettings.DatabaseUsername;
connectionInfo.Password = Program.SystemSettings.DatabasePassword;
connectionInfo.ServerName = Program.SystemSettings.DatabaseServer;
connectionInfo.DatabaseName = Program.SystemSettings.DatabaseDomainDatabase;
foreach (Table table in crystalReport.Database.Tables)
{
table.LogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(table.LogOnInfo);
}
This has resolved the issue.
Without applying on table level the report was connecting using the credentials supplied during the creating on the report in the Crystal Reports designer. The production server does not have access to the development server. I was able to identify this connection using procmon.
Hope this helps someone else.
Thanks,
Brent.
You can also get this error when you have problem with the stored procedure your report is based on. For me it was a user defined function in SQL Server, and I forgot to enable CLR after installation.
Searched for this error for couple of hours. Hope it helps someone
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks!!, this solved my problem.
in my case the problem was with a HANA report.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Brent
The search string 'crystal net memorystream' (search box in top right corner), comes up with the following KBA:
2105311 - ExportToStream throws exception in SP 12 in Crystal Reports for Visual Studio
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But what if you do an ExportToDisk (or plain Export with option DiskFileDestination? Even then the .NET Runtime calls the ExportToStream method:
Dim myExportOpts As New CrystalDecisions.Shared.ExportOptions
myExportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
Dim myExportFormatOpts As CrystalDecisions.Shared.PdfFormatOptions = CrystalDecisions.Shared.ExportOptions.CreatePdfFormatOptions
myExportFormatOpts.CreateBookmarksFromGroupTree = False
myExportFormatOpts.UsePageRange = False
Dim myExportDestinationOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = CrystalDecisions.Shared.ExportOptions.CreateDiskFileDestinationOptions
myExportDestinationOpts.DiskFileName = FileName
myExportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
myExportOpts.ExportFormatOptions = myExportFormatOpts
myExportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
myExportOpts.ExportDestinationOptions = myExportDestinationOpts
.Export(myExportOpts)
Gives (after approx. 300 exports) the following traceback with a "The system cannot find the path specified" error:
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options)
at MyApp.CrystalReport.SaveReport() in D:\Visual Studio 2010 projects\MyProject\MyApp\Forms\CrystalReport.vb:line 128
What to do now?
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.