繁体   English   中英

如何删除 Crystal Reports 13.0 版中的加载报告失败错误?

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

我正在使用 Crystal Report(版本 13.0)和 .NET Framework 4.0 以及 VS 2013 开发一个简单的应用程序。我正在做的是我在表单上有一个 Crystal 报表查看器,它应该在按钮时显示/加载我的报表被点击。 我加载报告的代码是:

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;
            }
        }
    }
}

我遇到的问题是,每当我单击按钮时,都会发生异常,说明如下:

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: 

我尝试过的解决方案是:

  1. 一遍又一遍地检查路径。
  2. 检查临时文件夹以及我的报告所在文件夹的文件权限。
  3. 检查 stackoverflow 以获得答案,但找不到有关我的问题详细信息的答案。

但一切都在血管中。 有人可以告诉我幕后发生了什么吗?

更新除了这个论坛,我还在 SAP 水晶报告论坛上发布了这个问题,有人回答说只是从路径中删除 @ 符号。 但是当我删除@ 符号时,出现了“无法识别的转义序列”错误。 请帮忙! SAP 社区网络的回答

尝试 :

网络

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

视窗

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

您的问题(如我的)可能仍与 RPT 文件的路径有关。 在 .aspx Web 表单中,您可能会受益于以下语法:

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

通过使用相对路径,经过数小时的反复试验,我能够执行我的报告文件。

MySql.Data.MySqlClient.MySqlDataAdapter myAdapter1 = new MySql.Data.MySqlClient.MySqlDataAdapter(ds.Tables[0].Rows[0]["Query"].ToString(), conn);
                    myAdapter1.Fill(myData);
                    WaitSumCrystalReport3 myr = new WaitSumCrystalReport3();
                    myr.SetDataSource(myData);
                    if (myData.Tables[0].Rows.Count > 0)
                        myr.PrintToPrinter(1, true, 1, 10);
                    cmd.CommandText = "Update tbl_print set Status='1' where ID='" + ds.Tables[0].Rows[0]["ID"].ToString() + "'";
                cmd.Connection = conn;
                cmd.ExecuteNonQuery();
//disposing the crystal report object to clear the temp memroy.. otherwise memory is overflow occurs in future
                    myr.Dispose();
//above statement is used to dispose... it will work fine

..

CryRpt.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CrystalReport1.rpt"));

并右键单击 CrystalReport1.rpt 转到属性并将构建操作设置为 Content 并将 CopyOutputDirectory 设置为 Copy if new..

希望它会帮助你,thanx

确保您的所有字段都正确填充。

一旦我遇到这种问题,在删除 sql 查询中的错误后解决了

我使用带有过滤器的Procmon.exe对我来说工作正常(访问拒绝某些文件夹):

https://stackoverflow.com/a/41942720/1536197

就我而言,我首先遇到错误: Could not load file or assembly 'CrystalDecisions.ReportAppServer.ClientDoc', Version=xxx' 然后我找到并添加对xxx version of CrystalDecisions.ReportAppServer.ClientDoc.dll引用,然后运行程序,出现新的错误Load Report Failed

询问同事后,我转到Project > Properties > Build取消选中Prefer 32-bit复选框,并恢复使用我使用的原始版本CrystalDecisions.ReportAppServer.ClientDoc.dll ,然后我可以成功生成报告。

此外,我已经安装了 64 位版本的Crystal Reports runtime engine

对于 ASP.NET Web 项目,转到

 Tools
  -> Options
   -> Projects and Solutions
    -> Web Projects
     -> Check "Use the 64 bit version of IIS Express for web sites and projects"`

参考: 如何强制 IIS Express 在 32 位模式下运行?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM