How to remove Load Report Failed Error in Crystal Reports version 13.0?

45,585

Solution 1

Try :

Web

 rpt.Load(Server.MapPath("\\CystalReportsApp\\CrystalReport1.rpt"))

Windows

rpt.Load(@"e:\\users\\shahid sultan minhas\\documents\\visual studio 2013\\Projects\\CystalReportsApp\\CystalReportsApp\\CrystalReport1.rpt")

Solution 2

Your problem (like mine) may still be related to the path to the RPT file. In an .aspx Web Form, you might benefit from this syntax:

    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        <Report FileName="~/MyCrystalReport.rpt">
        </Report>
    </CR:CrystalReportSource>

By using a relative path, I was able to execute my report files after many hours of trial-and-error.

Share:
45,585
Sameer
Author by

Sameer

Updated on May 28, 2021

Comments

  • Sameer
    Sameer almost 3 years

    I am developing a simple app using Crystal Report (Version 13.0) and .NET Framework 4.0 as well as VS 2013. What i am doing is that i have a Crystal report viewer on the form which is supposed to show/load my report when button is clicked. My code to load a report is:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using CrystalDecisions.CrystalReports.Engine;
    namespace CystalReportsApp
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    ReportDocument rpt = new ReportDocument();
                    rpt.Load(@"e:<path>\CystalReportsApp\CystalReportsApp\CrystalReport1.rpt");
                    crystalReportViewer1.ReportSource = rpt;
                    crystalReportViewer1.Refresh();
                }
                catch (Exception ex)
                {
    
                    throw;
                }
            }
        }
    }
    

    Problem i am getting is that whenever i click button, an exception occurs saying this:

    CrystalDecisions.Shared.CrystalReportsException was unhandled
    HResult=-2146232832
    Message=Load report failed.
    Source=CrystalDecisions.CrystalReports.Engine
    StackTrace:
       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)
       at CystalReportsApp.Form1.button1_Click(Object sender, EventArgs e) in e:\<path>\CystalReportsApp\Form1.cs:line 32
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at CystalReportsApp.Program.Main() in e:\<path>\CystalReportsApp\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.Runtime.InteropServices.COMException
        HResult=-2147467259
        Message=The system cannot find the path specified.    
        Source=Analysis Server
        ErrorCode=-2147467259
        StackTrace:
             at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
             at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
             at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
           InnerException: 
    

    Solutions i have tried are:

    1. Checked the path again and again.
    2. Checking file permissions on the temp folder as well as on the folder where my report resides.
    3. Checking stackoverflow for the answer but couldn't find an answer regarding my problem's details.

    But all in vein. Can somebody please tell me as what's going behind the scene?

    UPDATED Alongside this forum, i had also posted this question at SAP crystal reports' forum for which somebody answered as to just remove @ sign from the path. But as i remove @ sign, "Unrecognized escape sequence" errors come. Please help! Answer by SAP COMMUNITY NETWORK