找不到合适的方法来覆盖错误

时间:2017-02-09 10:53:27

标签: c#

如何解决这个问题?

  

错误2' School_Software.RptStudents.NewGenerator':找不到合适的方法来覆盖C:\ Users \ user \ Downloads \ Compressed \ school_software_0 \ School Software \ School Software \ RptStudents.cs 33 31 School Software

以下是我的代码

namespace School_Software {

public class RptFinalMarksLedger : ReportClass {

    public RptFinalMarksLedger() {
    }

    public override string ResourceName {
        get {
            return "RptFinalMarksLedger.rpt";
        }
        set {
            // Do nothing
        }
    }

    public override bool NewGenerator {
        get {
            return true;
        }
        set {
            // Do nothing
        }
    }

    public override string FullResourceName {
        get {
            return "School_Software.RptFinalMarksLedger.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 CachedRptFinalMarksLedger : Component, ICachedReport {

    public CachedRptFinalMarksLedger() {
    }

    [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() {
        RptFinalMarksLedger rpt = new RptFinalMarksLedger();
        rpt.Site = this.Site;
        return rpt;
    }

    public virtual string GetCustomizedCacheKey(RequestContext request) {
        String key = null;

        return key;
    }
}

}

2 个答案:

答案 0 :(得分:0)

您正在尝试覆盖未在基类中定义的属性(NewGenerator)。

只需删除override关键字:

即可
public bool NewGenerator {
    get {
        return true;
    }
    set {
        // Do nothing
    }
}

答案 1 :(得分:0)

 public class CADExpertInitalizeDB : DropCreateDatabaseIfModelChanges <CADExpertContext>
    {
        protected  override void Seed(CADExpertContext context)
        {
            context.CADExperts.Add(new CADExpert { Id = 1, Name = "Rice", inStock = true, Price = 30 });
            context.CADExperts.Add(new CADExpert { Id = 2, Name = "Sugar", inStock = false, Price = 40 });
            context.SaveChanges();
            base.Seed(context);
        }
    }