gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:22:24 24 4
gpt4 key购买 nike

我正在使用 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 Crystal Reports 的论坛上发布了这个问题,有人回答说只是从路径中删除 @ 符号。但是当我删除@符号时,出现“无法识别的转义序列”错误。请帮忙! Answer by SAP COMMUNITY NETWORK

最佳答案

尝试:

网络

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

window

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

关于c# - 如何删除 Crystal Reports 13.0 版中的加载报告失败错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27108976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com