Skip to Content

CRforVS_13_0_18 with VS 2010 - System Cannot Find Path Specified

Nov 18, 2016 at 04:43 PM


avatar image
Former Member


I'm trying to export a Crystal Report using RAS and the CRforVS_13_0_18 SDK for .Net using WPF and Visual Studio 2010. The export fails on this series of code (last line):

rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF; rasPrintOutputController = doc.PrintOutputController;

ByteArray tempByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0);

The error message is "The system cannot find the path specified" in source rptcontrollers.dll with error code -2147467259.

I believe the logic is fine because I'm able to use the same logic and settings in Java and it pulls the report with no problems in less than a second. I would assume that the issue takes root in the connection to the database, but unless I'm missing some settings for Oracle, it seems like the code is correct.

Here is the operation that tries to export the report:


private void exportRASReport()
            //Crystal Server
            String sCrystalHost = Properties.Settings.Default.sCrystalHost;

            //Report template
            //The .rpt file has to exist on the server where the Crystal engine is 
            String reportName = Properties.Settings.Default.sReportPath;
            Object reportPath = (Object)reportName;

            //Database Settings
            String sDBHost = Properties.Settings.Default.sDBHost;
            String sDBSID = Properties.Settings.Default.sDBSID;
            String sDBUser = Properties.Settings.Default.sDBUser;
            String sDBPass = Properties.Settings.Default.sDBPass;
            //Report parameters
            Dictionary<String, Object> parameters = new Dictionary<String, Object>();

            parameters.Add("SPUser", "Coordinator");
            parameters.Add("SPTimeZone", "GMT");
            parameters.Add("SPQueryHeading", "Whatever!");

            ReportClientDocument doc = new ReportClientDocument();
                doc.ReportAppServer = sCrystalHost;

                doc.Open(ref reportPath, (int)CdReportClientDocumentOpenOptionsEnum.cdReportClientDocumentOpenAsReadOnly);

                //Set up Propert Bags for connecting to DB
                PropertyBag logonProps = new PropertyBag();
                logonProps.Add("Server", sDBSID);

                PropertyBag pBag = new PropertyBag();
                pBag.Add("QE_ServerDescription", sDBSID);
                pBag.Add("QE_SQLDB", true);
                pBag.Add("QE_DatabaseType", "Oracle Server");
                pBag.Add("Database DLL", "crdb_oracle.dll");
                pBag.Add("QE_LogonProperties", logonProps);

                //Create the ConnectionInfo object
                ConnectionInfo ci = new ConnectionInfo();
                ci.Attributes = pBag;
                ci.UserName = sDBUser;
                ci.Password = sDBPass;
                ci.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;

                //replace old data source with new datasource
                DatabaseController databaseController = doc.DatabaseController;
                ConnectionInfos connectionInfos = databaseController.GetConnectionInfos(null);
                ConnectionInfo oldConnectionInfo = connectionInfos[0];

                databaseController.ReplaceConnection(oldConnectionInfo, ci, null, (int)CrDBOptionsEnum.crDBOptionUseDefault + (int)CrDBOptionsEnum.crDBOptionDoNotVerifyDB);

                //set parameters for the report
                foreach (KeyValuePair<String, Object> kvp in parameters)
                    doc.DataDefController.ParameterFieldController.SetCurrentValue("", kvp.Key.ToString(), kvp.Value.ToString());

                //Set filter for a specific table and record
                String sRecordNumber = "12345";
                String sFilterText = "{*TableName*.id} = " + sRecordNumber; //Table name removed for privacy reasons
                Filter iFilter = doc.DataDefController.DataDefinition.RecordFilter;
                iFilter.FreeEditingText = sFilterText;

                PrintOutputController rasPrintOutputController;
                CrReportExportFormatEnum rasReportExportFormat;

                rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF;
                rasPrintOutputController = doc.PrintOutputController;
                ByteArray tempByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0); //this is the line that causes the error
                Byte[] byteStreamOutput = tempByteArray.ByteArray;

                String sSavePathName = @"C:\Output\export.pdf";

                FileStream fs = new FileStream(sSavePathName, FileMode.Create, FileAccess.ReadWrite);
                int maxSize = byteStreamOutput.Length;
                fs.Write(byteStreamOutput, 0, maxSize);

            catch (Exception e)
                if (doc != null)
                        if (doc.IsOpen)
                    catch (Exception e) { }
10 |10000 characters needed characters left characters exceeded
Former Member

Also, here are the dll's used in the project, which are found in the

C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet


CRVsPackageLib.dll CrystalDecisions.CrystalReports.Design.dll CrystalDecisions.CrystalReports.Engine.dll CrystalDecisions.CrystalReports.TemplateEngine.dll CrystalDecisions.Data.AdoDotNetInterop.dll CrystalDecisions.Enterprise.Viewing.ReportSource.dll CrystalDecisions.ReportAppServer.ClientDoc.dll CrystalDecisions.ReportAppServer.CommLayer.dll CrystalDecisions.ReportAppServer.CommonControls.dll CrystalDecisions.ReportAppServer.CommonObjectModel.dll CrystalDecisions.ReportAppServer.Controllers.dll CrystalDecisions.ReportAppServer.CubeDefModel.dll CrystalDecisions.ReportAppServer.DataDefModel.dll CrystalDecisions.ReportAppServer.DataSetConversion.dll CrystalDecisions.ReportAppServer.ObjectFactory.dll CrystalDecisions.ReportAppServer.Prompting.dll CrystalDecisions.ReportAppServer.ReportDefModel.dll CrystalDecisions.ReportAppServer.XmlSerialize.dll CrystalDecisions.ReportSource.dll CrystalDecisions.Shared.dll CrystalDecisions.VSDesigner.dll CrystalDecisions.Web.dll CrystalDecisions.Windows.Forms.dll FlashControlV71.dll SAPBusinessObjects.WPF.Viewer.dll SAPBusinessObjects.WPF.ViewerShared.dll ShockwaveFlashObjects.dll
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Don Williams
Nov 23, 2016 at 06:55 PM

Hi Rex,

Using CR for VS you need to open the reports with the engine, then if you want to use RAS convert the ClientDoc to ReportClientDoc.

Download the sample app I included in in the Printer or Parameter app in KBA 2163438 and 2281780.

It has examples of how to open a report and convert to RAS.


10 |10000 characters needed characters left characters exceeded
Don Williams
Nov 18, 2016 at 09:28 PM

Hi Rex,

Don't browse to the CR Assemblies, use the Add Reference feature in VS and select them from the GAC:

This one is definitely not a Version 13 dll:

CrystalDecisions.Enterprise.Viewing.ReportSource.dll CrystalDecisions.ReportAppServer.ClientDoc.dll

And you likely don't need this one:

CrystalDecisions.ReportAppServer.CubeDefModel.dll CrystalDecisions.ReportAppServer.DataDefModel.dll

And you did not include the Controller, just like the error indicates:

using CrystalDecisions.ReportAppServer.Controllers;

Also, I recommend using the WinForm Viewer rather than the WPF viewer. It's much more mature and has a lot more features available.


dckf1.png (28.6 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi, Don.

Thank you very much for your response!

I've created a new Windows Forms project, copied in the same source code (in the .txt file), added the assemblies via Project > Add Reference (from the GAC). I've attached a screenshot of the added references, and here are all the 'using's in my my project:

using System;

using System.Collections.Generic;

using System.IO;

using System.Windows.Forms;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.CommonObjectModel;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.DataDefModel;

using CrystalDecisions.ReportAppServer.ReportDefModel;

I am getting the same error message at the same line of code:

Message = "The system cannot find the path specified.\r"

StackTrace = " at CrystalDecisions.ReportAppServer.Controllers.ISCRPrintOutputController.Export(CrReportExportFormatEnum exportFormat, Int32 Reserved)\r\n at Crystal_TW_Printer_WFA.Form1.btnReports_Click(Object sender, EventArgs e) in ...

By the way, I don't want to view the report in the .Net application. I simply want to export the report as a PDF file and save it to my computer. I'm not sure if that has an impact on your response.

Thanks again!

I really appreciate your help.