简体   繁体   English

VS2022上的水晶报表

[英]Crystal Report on VS2022

I have installed CR13SP33 x86 & x64 runtime and also installed CRforVS6413 and I am able to get crystalReportViewer on ToolBar, create ASP.NET with .net framework 4.8, and dragged the control to the aspx page.我已经安装了 CR13SP33 x86 和 x64 运行时,还安装了 CRforVS6413,我能够在工具栏上获取 crystalReportViewer,使用 .net 框架 4.8 创建 ASP.NET,并将控件拖到 aspx 页面。 but on design view, I am getting the following error, and on execution its blank page, note that my crystal report file already has data in it但是在设计视图上,我收到以下错误,并在执行它的空白页时,请注意我的水晶报表文件中已经包含数据

在此处输入图像描述

this is my aspx code这是我的 aspx 代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" width="1200px" Height="800px"/>
</body>
</html>

web.xml config file web.xml 配置文件

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.8">
      <assemblies>
        <add assembly="CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.Shared, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669E0DDF0BB1AA2A"/>
        <add assembly="CrystalDecisions.ReportSource, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
        <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.8"/>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>

and my C# code to load CRystal report file和我的 C# 代码加载 CRystal 报告文件

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ReportDocument myReportDocument;
            myReportDocument = new ReportDocument();
            myReportDocument.Load(@"C:\Users\Serak\source\repos\WebApplication1\WebApplication1\ConsolidatedBalanceSheet.rpt");
            CrystalReportViewer1.ReportSource = myReportDocument;
            CrystalReportViewer1.DisplayToolbar = true;
        }
    }
}
  1. Open the project, right-click the project, and add a reference.打开项目,右键单击项目,然后添加引用。

  2. Click Browse to go to program files/crystal Decisions/crystal report9, and search (including subdirectories) 'CrystalDecisions.VSDesigner.dll' below.单击浏览到 go 到程序文件/crystal Decisions/crystal report9,并在下面搜索(包括子目录)'CrystalDecisions.VSDesigner.dll'。 Then OK.然后确定。

  3. If prompted, select "Yes".如果出现提示,select“是”。

  4. Drag a ReportViewer to the view, there should be no error.拖一个ReportViewer到视图中,应该没有错误。

You need to add the following code in web.config:需要在web.config中添加如下代码:

     <system.web>
        <compilation defaultLanguage="c#" debug="true"><assemblies><add assembly="CrystalDecisions.CrystalReports.Engine, 

Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.ReportSource, 

Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Shared, 

Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Web, 

Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies></compilation>

     </system.web>

The version I use is different from yours, you need to change the relevant configuration according to your own information.我用的版本和你的不一样,你需要根据自己的信息更改相关配置。

Your web.config file looks fine.您的 web.config 文件看起来不错。

Must set Copy Local to False so it doesn't load the wrong dll's, your \bin folder must have no CR dll's in it.必须将 Copy Local 设置为 False,这样它就不会加载错误的 dll,您的 \bin 文件夹中必须没有 CR dll。

Check out this blog I wrote to upgrade your project to VS 2022: https://blogs.sap.com/2020/10/30/upgrading-a-visual-studio-2008-2019-.net-project-with-the-latest-cr-.net-sdk-packages/查看我写的这篇博客,将您的项目升级到 VS 2022: https://blogs.sap.com/2020/10/30/upgrading-a-visual-studio-2008-2019-.net-project-with-the -最新-cr-.net-sdk-包/

Problem is IIS can't find the CR viewer in here, or similar: C:\.netpub\wwwroot\as.net_client\system_web\4_6_81\crystalreportviewers13问题是 IIS 在这里找不到 CR 查看器,或类似的:C:\.netpub\wwwroot\as.net_client\system_web\4_6_81\crystalreportviewers13

Copy this folder into your Project: crystalreportviewers13将此文件夹复制到您的项目中:crystalreportviewers13

My blog has a sample web.config file that does work.我的博客有一个示例 web.config 文件可以正常工作。

Don大学教师

Please register the content on your aspx page:请在您的 aspx 页面上注册内容:

< %@ Register Assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.CrystalReports.Engine" TagPrefix="CR" %>

< %@ Register Assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.ReportSource" TagPrefix="CR" %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM