如何删除 Crystal Reports 版本 13.0 中的加载报告失败错误
本文关键字:加载 报告 错误 失败 版本 何删除 删除 Reports Crystal | 更新日期: 2023-09-27 18:31:56
>我正在使用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:
我尝试过的解决方案是:
- 一遍又一遍地检查路径。
- 检查临时文件夹以及报表所在的文件夹的文件权限。
- 检查堆栈溢出以获取答案,但找不到有关我问题详细信息的答案。
但一切都在脉络中。有人可以告诉我幕后发生了什么吗?
更新除了这个论坛,我还在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"));
并右键单击 水晶报告1.rpt 转到属性并设置构建内容操作和CopyOutputDirectory 如果较新,则要复制。.
希望它能帮助你,感谢
确保所有字段都正确填充。
有一次我遇到这种问题,在删除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 位模式运行?