与Crystal Reports有关的C#程序集问题

本文关键字:程序集 问题 Crystal Reports | 更新日期: 2023-09-27 17:59:17

我在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报表中的库都没有解析,即使它们被添加为在解决方案资源管理器右侧可见的引用。以下是生成问题的模块中的代码,它都是由VisualStudio自动生成的

//------------------------------------------------------------------------------
// <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;
        }
    }
}

如有任何帮助,我们将不胜感激。

与Crystal Reports有关的C#程序集问题

检查您的项目属性。可能是针对.NET Framework 4客户端配置文件。将其更改为.NET Framework 4。问题将得到解决。

因此,将其更改为.Net Framework 4配置文件,而不是.Net Framework 4客户端配置文件修复了它。

AddReferenceCrystalDecisions.ReportSource