【发布时间】:2011-09-16 22:13:15
【问题描述】:
我在我的 Visual Studio C# 项目中添加了一个水晶报表。我在添加报告之前成功运行了代码。仅添加报告后,我无法再编译。我收到以下编译器错误
"Error 23 'SureSalePos.InvoiceReport' does not contain a definition for 'ReportDefinition' and no extension method 'ReportDefinition' accepting a first argument of type 'SureSalePos.InvoiceReport' could be found (are you missing a using directive or an assembly reference?) F:\VS2010\Projects\Sure Sale Pos\Sure Sale Pos\InvoiceReport.cs 55 29 Sure Sale Pos"
"Error 20 The type or namespace name 'Engine' does not exist in the namespace 'CrystalDecisions.CrystalReports' (are you missing an assembly reference?) F:\VS2010\Projects\Sure Sale Pos\Sure Sale Pos\InvoiceReport.cs 16 43 Sure Sale Pos"
Crystal Reports 中的所有库都没有解析,即使它们被添加为我的解决方案资源管理器右侧可见的引用。以下是生成问题的模块中的代码,它都是由 Visual Studio 自动生成的
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SureSalePos {
using System;
using System.ComponentModel;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports.Engine;
public class InvoiceReport : ReportClass {
public InvoiceReport() {
}
public override string ResourceName {
get {
return "InvoiceReport.rpt";
}
set {
// Do nothing
}
}
public override bool NewGenerator {
get {
return true;
}
set {
// Do nothing
}
}
public override string FullResourceName {
get {
return "SureSalePos.InvoiceReport.rpt";
}
set {
// Do nothing
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public CrystalDecisions.CrystalReports.Engine.Section Section1 {
get {
return this.ReportDefinition.Sections[0];
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public CrystalDecisions.CrystalReports.Engine.Section Section2 {
get {
return this.ReportDefinition.Sections[1];
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public CrystalDecisions.CrystalReports.Engine.Section Section3 {
get {
return this.ReportDefinition.Sections[2];
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public CrystalDecisions.CrystalReports.Engine.Section Section4 {
get {
return this.ReportDefinition.Sections[3];
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public CrystalDecisions.CrystalReports.Engine.Section Section5 {
get {
return this.ReportDefinition.Sections[4];
}
}
}
[System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")]
public class CachedInvoiceReport : Component, ICachedReport {
public CachedInvoiceReport() {
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual bool IsCacheable {
get {
return true;
}
set {
//
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual bool ShareDBLogonInfo {
get {
return false;
}
set {
//
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.TimeSpan CacheTimeOut {
get {
return CachedReportConstants.DEFAULT_TIMEOUT;
}
set {
//
}
}
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
InvoiceReport rpt = new InvoiceReport();
rpt.Site = this.Site;
return rpt;
}
public virtual string GetCustomizedCacheKey(RequestContext request) {
String key = null;
// // The following is the code used to generate the default
// // cache key for caching report jobs in the ASP.NET Cache.
// // Feel free to modify this code to suit your needs.
// // Returning key == null causes the default cache key to
// // be generated.
//
// key = RequestContext.BuildCompleteCacheKey(
// request,
// null, // sReportFilename
// this.GetType(),
// this.ShareDBLogonInfo );
return key;
}
}
}
任何帮助都非常感谢提前感谢。
【问题讨论】:
-
首先,你不需要发布所有垃圾代码
-
您使用的是什么版本的 VS,您的目标是什么 .net 框架版本(如果适用)?水晶报表程序集的目标是什么 .net 框架版本?
-
VS 2010,.Net Framework 4 客户端配置文件。我在水晶报告的版本控制中唯一能找到的是水晶报告 2011
-
因此将其更改为 .Net Framework 4 配置文件而不是 .Net Framework 4 客户端配置文件已修复它。
标签: c# crystal-reports assemblies reference