问题
I made a report using crystal report and in the page load I am writing this
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;
}
and when runing the page I found this error.
CS0433: The type 'CrystalDecisions.Web.CrystalReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Web\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Web.dll' and 'c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Web\13.0.2000.0__692fbea5521e1304\CrystalDecisions.Web.dll'
回答1:
I found this tag in my web.config
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
and in my aspx page
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
different version for the same assembly makes the conflict so I removed web.config tag and it runs very smooth.
thanks.
回答2:
Copy-paste this (Version=13.0.2000.0)
from web config to the default ASPX
source code where you found different versions of Crystal Report and the error will be fixed.
来源:https://stackoverflow.com/questions/4736803/error-when-creating-crystal-report-in-asp-net-mvc2