[英]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:
我嘗試過的解決方案是:
但一切都在血管中。 有人可以告訴我幕后發生了什么嗎?
更新除了這個論壇,我還在 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對我來說工作正常(訪問拒絕某些文件夾):
就我而言,我首先遇到錯誤: 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"`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.