Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调用重写方法_C#_Asp.net_Overriding - Fatal编程技术网

C# 调用重写方法

C# 调用重写方法,c#,asp.net,overriding,C#,Asp.net,Overriding,我有以下代码: public class CustomContentBlock : ContentBlock { public override void Fill() { this._Item.Html = replace_dangerous_entities(this._Item.Html); base.Fill(); } } public class ContentBlock : EkXsltWebPart, IEnumerator

我有以下代码:

public class CustomContentBlock : ContentBlock
{
    public override void Fill()
    {
        this._Item.Html = replace_dangerous_entities(this._Item.Html);
        base.Fill();
    }
}

public class ContentBlock : EkXsltWebPart, IEnumerator, IEnumerable, IListSource, IDataSource, ICallbackEventHandler
{
    protected ContentBase _Item;

    public override void Fill()
    {
        if (this.Dirty && base.CallBackCheck())
        {
            this._FillCount++;
            if (!base.DesignTime)
            {
                if (this.ContentID == 0L)
                {
                    return;
                }
                this.SetContentLanguage();
                this.ReadCachedItem();
                if (this._Item == null)
                {
                    ApiSupport.ContentResult contentResult = base.Connection.api.LoadContent(this.ContentID, base.Connection.api.CmsPreview, this.GetAnalyticsData);
                    if (contentResult.Item != null && Convert.ToInt64(contentResult.Item.ContentType) == 102L)
                    {
                        string pattern = "scrolling=\"yes\"";
                        contentResult.Item.Html = Regex.Replace(contentResult.Item.Html, pattern, "");
                    }
                    if (contentResult.Item != null && contentResult.Item.ContentType == EkEnumeration.CMSContentType.Multimedia && base.Connection.api.CmsPreview && contentResult.Item.Status.ToString().ToUpper() != "A")
                    {
                        string oldValue = string.Concat(new string[]
                        {
                            base.Connection.api.RequestInformationRef.AssetPath, 
                            base.Connection.api.EkContentRef.GetFolderParentFolderIdRecursive(contentResult.Item.FolderId).Replace(",", "/"), 
                            "/", 
                            contentResult.Item.AssetInfo.Id, 
                            ".", 
                            contentResult.Item.AssetInfo.FileExtension
                        });
                        contentResult.Item.Html = contentResult.Item.Html.Replace(oldValue, string.Concat(new string[]
                        {
                            base.Connection.api.SitePath, 
                            "assetmanagement/DownloadAsset.aspx?history=true&ID=", 
                            contentResult.Item.AssetInfo.Id, 
                            "&version=", 
                            contentResult.Item.AssetInfo.Version
                        }));
                    }
                    this.ResetContentLanguage();
                    if (contentResult.ErrorMessage != string.Empty)
                    {
                        throw new Exception(contentResult.ErrorMessage);
                    }
                    this._Item = contentResult.Item;
                    base.NormalizeBase(ref this._Item);
                    if (this._Item != null && !contentResult.Item.IsPrivate && Cache.Cacheable(false))
                    {
                        Cache.PutCache(this._identifier, this._Item, this.CacheInterval);
                    }
                }
                this.CreateDataSet();
                base.CatalogIconImageUrl = base.Connection.api.ApplicationPath + "images/application/icon_document.gif";
                base.TitleIconImageUrl = "";
                base.Title = this._Item.Title;
            }
            this.BuildOutput();
            base.SetClean();
        }
    }
}  
但我总是会收到一个错误提示:
stackoverflowexception发生在mscorlib.dll中
base.Fill()


ContentBlock
不是我们编写的。

基类中是否有实现,或者它只是一个抽象的实现?通过JetBrains或Telerik one之类的免费反编译程序进行检查。更新:为了准确地找到原因,您应该进入调试模式,在填充行中点击一个断点,然后点击F9进入下一个方法,通过检查调用堆栈窗口,您可以找到无限循环的起始位置以及这是什么。_Item
?字段或属性?是否可以发布跟踪的提示(例如前10帧)?它应该指示故障发生的位置并点击F5几次,然后查看Stacktrace窗口。在继承链的某个地方,Fill()调用Fill(),它调用CustomContentBlock::Fill(),因为您已经覆盖了它。这个无限递归循环导致堆栈溢出。正如人们所提到的,检查堆栈跟踪以准确查看调用的内容以及无限递归发生的位置。