Crystal Reports for Visual Studio 2010错误

Kum*_*mar 17 c# visual-studio-2010 crystal-reports asp.net-4.0

我正在尝试使用ASP.NET 4.0和Visual Studio 2010从我的Web应用程序运行水晶报表.我已经从SAP站点安装了以下内容(http://www.businessobjects.com/jump/xi/crvs2010 /us2_default.asp)

1)SAP Crystal Reports,Visual Studio 2010版本 - 标准EXE安装包,用于将软件安装到Visual Studio IDE中.

2)用于.NET Framework 4的SAP Crystal Reports运行时引擎(64位)

我有一个名为Reports.aspx的页面,其中我有一个水晶报表查看器控件

 <CR:CrystalReportViewer ID="rptViewer" runat="server" AutoDataBind="true" />
Run Code Online (Sandbox Code Playgroud)

在Reports.aspx.cs文件中,我有以下代码:

protected override void OnPreRender(EventArgs e)
{
    ReportDocument report = new ReportDocument();
    var path = Server.MapPath("Reports/Sample.rpt");
    report.Load(path);
    report.SetDatabaseLogon("username", "password", "servername", "databasename");
    rptViewer.ReportSource = report;
}
Run Code Online (Sandbox Code Playgroud)

在report.Load(path)行上,我收到以下错误:

不支持的操作.由JRC引擎处理的文档无法在C++堆栈中打开.

我怎样才能解决这个问题?

Pri*_*n R 13

我也得到了同样的问题我的问题是报告的路径是无效的,可能是你有同样的问题,检查使用Server.Mappath("报告/ Sample.rpt")返回有效的路径?


Ali*_*ini 10

确保报告在app_code文件夹中初始化它的新实例,而不是初始化报告文档并在其中加载报告.

Sample report = new Sample();
Run Code Online (Sandbox Code Playgroud)

这对我有用


ale*_*nso 6

您需要修改.rpt文件中的两个属性:

  1. 默认情况下,Build Action设置为"Embedded Resource".将其更改为" 内容 ".
  2. 默认情况下," 复制到输出 "设置为"不复制".将其更改为" 始终复制 ".

重建,构建部署包和发布.完成!


小智 5

注意:下面,术语"WebSite"指的是IIS中的实际网站节点,而不是网站中的虚拟目录.

问题根本原因:应用程序无法访问"aspnet_client"文件夹.
出现这种情况有几个原因:

  1. 由于SAP CR安装程序似乎在...\inetpub\wwwroot \文件夹中安装了aspnet_client文件夹,如果您的网站物理路径不是...\inetpub\wwwroot,您的应用程序将无法访问aspnet_client文件夹.
  2. 如果将aspnet_client文件夹移动或删除到网站物理路径的顶层,则IIS应用程序将无法访问该文件夹.

问题解决方案(适用于Windows Server 2008 R2)

  1. 转到服务器上的IIS管理器
  2. 展开运行应用程序的WebSite的树视图节点
  3. 查看网站节点下的级别,确保您看到"aspnet_client"文件夹.
  4. 如果您确实看到了该文件夹,那么这个根本原因可能不是您的问题的原因.
  5. 如果您没有看到该文件夹​​,请搜索服务器的硬盘驱动器并将其复制到网站的物理路径.
  6. 在"网站"节点上单击鼠标右键,然后从弹出菜单中单击"刷新"
  7. 您现在应该直接在网站节点下的级别看到aspnet_client文件夹,并且应用程序中的报告应该可以正常工作.