【问题标题】:Error when creating crystal report in asp.net mvc2在 asp.net mvc2 中创建水晶报表时出错
【发布时间】:2025-12-06 19:40:01
【问题描述】:

我使用水晶报告做了一个报告,在页面加载中我正在写这个

protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument crystalReport = new ReportDocument();
        crystalReport.Load(Server.MapPath("CrystalReport.rpt"));
        crystalReport.SetDatabaseLogon
            ("amit", "password", @"AMIT\SQLEXPRESS", "TestDB");
        CrystalReportViewer1.ReportSource = crystalReport;
    }

在运行页面时我发现了这个错误。

CS0433:“c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Web\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Web.dll”和“c:\Windows\assembly”中都存在“CrystalDecisions.Web.CrystalReportViewer”类型\GAC_MSIL\CrystalDecisions.Web\13.0.2000.0__692fbea5521e1304\CrystalDecisions.Web.dll'

【问题讨论】:

    标签: visual-studio-2010 asp.net-mvc-2 crystal-reports


    【解决方案1】:

    我在我的 web.config 中找到了这个标签

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

    在我的 aspx 页面中

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

    同一程序集的不同版本会产生冲突,所以我删除了 web.config 标记,它运行非常流畅。

    谢谢。

    【讨论】:

      【解决方案2】:

      将此(Version=13.0.2000.0) 从网络配置复制粘贴到默认的ASPX 源代码中,您在该源代码中发现了不同版本的 Crystal Report,错误将得到修复。

      【讨论】: