Visual Studio 2010 的水晶报表错误
我正在尝试从使用 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(64 位)的 SAP Crystal Reports 运行时引擎
我有一个名为 Reports.aspx 的页面,其中有一个水晶报表查看器控件
<CR:CrystalReportViewer ID="rptViewer" runat="server" AutoDataBind="true" />
在 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;
}
: report.Load(path) 行出现以下错误:
不支持的操作。无法在 C++ 堆栈中打开 JRC 引擎处理的文档。
如何解决此问题?
I am trying to run a crystal report from my web application which was built using ASP.NET 4.0 and Visual Studio 2010. I have installed the following from the SAP site (http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp)
1) SAP Crystal Reports, version for Visual Studio 2010 - Standard EXE installation package which installs the software into the Visual Studio IDE.
2) SAP Crystal Reports runtime engine for .NET Framework 4 (64-bit)
I have a page called Reports.aspx in which I have a crystal report viewer control
<CR:CrystalReportViewer ID="rptViewer" runat="server" AutoDataBind="true" />
In the Reports.aspx.cs file I have the following code:
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;
}
On the report.Load(path) line I get the following error:
Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我也遇到了同样的问题,我的问题是报告路径无效,可能你有同样的问题,检查 Server.MapPath("Reports/Sample.rpt") 返回有效路径?
I also got into the same problem my problem was report path was not valid, May be you have same problem , check Server.MapPath("Reports/Sample.rpt") returning valid path ?
确保报告位于
app_code
文件夹中初始化它的新实例,而不是初始化报告文档并在其中加载报告。
这对我有用
make sure the report is in
app_code
folderinitialize a new instance of it instead of initializing a reportdocument and loading the report in it.
this worked for me
您需要修改 .rpt 文件中的两个属性:
重建、构建部署包并发布。完毕!
You will need to modify two properties in the .rpt files:
Rebuild, Build deployment package and Publish. Done!
注意:下面的术语“网站”指的是 IIS 中的实际网站节点,而不是网站内的虚拟目录。
问题根本原因:应用程序无法访问“aspnet_client”文件夹。
发生这种情况的原因有多种:
问题解决方案(对于 Windows Server 2008 R2)
NOTE: Below, the term "WebSite" refers to actual web site nodes in IIS, NOT a virtual directory within a web site.
Problem Root Cause: There is no "aspnet_client" folder accessible by the application.
This can happen for several reasons:
Problem Solution (For Windows Server 2008 R2)
当我将网站转换为网络应用程序时,我遇到了这个问题。该报告可以在我的开发机器上正常运行,但不能在服务器上运行。然后我意识到服务器上的 rpt 文件丢失了!
默认情况下,报告文件被视为嵌入资源,并且在发布 Web 应用程序时不会复制。我只是单独更改了它们,重新发布了网站,一切又恢复正常了。
I ran into this when I converted a web site to a web application. The report would run fine on my dev machine, but not on the server. Then I realized the rpt file was missing on the server!
By default the report files were considered embedded resources and were not copied when the web application was published. I just changed them individually, republished the site, and all was well again.
如果我错误地在水晶报表设计器中打开报表文件,我也会遇到报表加载失败的情况。
I have also had a report load failure if I have mistakenly left the report file open in crystal reports designer.
这个错误确实是一种享受,而且似乎有很多可能的前因。幸运的是,我只在我的特定变体上浪费了一天的时间:
ReportDocument.Load()
还制作了本地临时副本。 (这可能仅适用于从网络驱动器位置加载的情况,我没有在本地加载的情况下测试这一点。)如果发生加载的用户上下文没有创建临时文件的权限在本地,
Load
将失败,并出现同样非常无用的错误。另外,我最终使用进程监视器对此进行了诊断。它可能对您也有帮助。
This error is a real treat, and seems to have many possible antecedents. Fortunately I only wasted a day on my particular variation:
ReportDocument.Load()
also makes a local temp copy. (This may only be in the case of a load from a network drive location, I didn't test this in the case of a local load.)If the user context under which the load occurs does not have authority to create the temp file locally,
Load
will fail with the same very unhelpful error.Also, I ended up diagnosing this with Process Monitor. It may be helpful for you as well.
请确保您的报告 rpt 文件位于其原始文件夹中。在我将 MVC 网站“发布”到 IIS 后,我首先遇到了同样的错误。我没有意识到“发布”并没有将rpt文件放入包中。
Please make sure your report rpt files are in their original folder. I got the same error first, after I "published" my MVC web site to IIS. I didn't realize that "Publish" didn't put rpt files in the package.
将“Crystal 报表引擎”重新安装到服务器
构建操作设置为“内容”。
它对我来说非常有效......!
Re-install the "Crystal report engine" to the server
Build Action set to "Content".
It perfectly worked for me..!