More in this section

Forums / Developing with Sitefinity / An attempt was made to reference a CacheDependency object from more than one Cache entry

An attempt was made to reference a CacheDependency object from more than one Cache entry

12 posts, 0 answered
  1. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    08 Jun 2009
    Link to this post
    hello Sitefinity Team

    I am trying to optimize the performance of a page in my website. So I selected Yes for the option 'Cache this page'.

    The first call to this page results in the error 'An attempt was made to reference a CacheDependency object from more than one Cache entry.

    When I make a call the second time it shows the page perfectly. When the Cache period time has been expired, the erro occurs again.
    On this page a library with images is presented.

    Have you any idea what the problem could be?

    Kind regards
    Luc
  2. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    08 Jun 2009
    Link to this post
    Hi Luc Baeten,

    What is the Sitefinity version of your Web Site?

    Similar bug was found in v3.5 and fixed in v3.6 SP1. It was related to the RadAjaxPanel, because it calls page rendering internally, which causes SetAspNetCachebility() method to be called twice.

    If this is your case, upgrading to the latest version should fix the problem. Alternatively, you can use the following work around:
    Create a class CustomInternalPage (inherited from InternalPage) in the App_Code:
    using Telerik.Cms.Web; 
     
    public class CustomInternalPage : InternalPage 
        protected override void SetAspNetCachebility(System.Web.Caching.CacheDependency dependency, Telerik.Caching.ICacheSettings cacheSettings) 
        { 
            if (!this.rendering) 
            { 
                this.rendering = true
                base.SetAspNetCachebility(dependency, cacheSettings); 
            } 
        } 
     
        private bool rendering = false
     

    And set the class as a code behind of ~/Sitefinity/cmsentrypoint.aspx page:
    <%@ Page Inherits="CustomInternalPage" MasterPageFile="~/Sitefinity/Dummy.master" %> 


    If you don't have RadAjaxPanel on the page, could you please send us a list of the exact controls added to the page?

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    16 Jun 2009
    Link to this post
    In fact, this website is ruuning under version 3.5 of Sitefinity. I will try your work around.

    Thanks
    Luc Baeten
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Jun 2009
    Link to this post
    Hi Luc Baeten,

    If the workaround does not work for you (which I don't think the case will be), you might try to upgrade the project.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Jim Aderhold
    Jim Aderhold avatar
    48 posts
    Registered:
    29 Feb 2004
    28 Jan 2010
    Link to this post
    We are experiencing the same problem with this. I have updated the CMSEntryPoint.aspx file with the overridden method and I am still having problems. We do not have the RadAjaxPanel just the RadScriptManager and RadAjaxManager on the master page. As for the pages in question, the only controls added to the pages through Sitefinity are the SiteMenu and SitePanelBar controls. We are running 3.5.1747 and an upgrade is not an option right now.
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    29 Jan 2010
    Link to this post
    Hello Jim Aderhold,

    Where do you experience the error, in the front end or in the backend when you preview the page? Upgrading is the best way to get the error fixed natively though. 

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Jim Aderhold
    Jim Aderhold avatar
    48 posts
    Registered:
    29 Feb 2004
    29 Jan 2010
    Link to this post
    The error only seems to occur on the front end. The preview mode seems to render it just fine. I was able to navigate to other pages and come back without any problems. On the front end, the first request threw the error.
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Feb 2010
    Link to this post
    Hello Jim Aderhold,

    Can you please provide us with your log file? Most probably the problem is provoked at a different place. The RadScriptManager and RadAjaxManager should not cause such issue either - they doesn't do any postbacks.

    We will check the stack trace and will get back to you.

    Kind regards,
    Georgi
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  9. Jim Aderhold
    Jim Aderhold avatar
    48 posts
    Registered:
    29 Feb 2004
    02 Feb 2010
    Link to this post
    2/2/2010 7:15:27 AM [UNKNOWN]
    ************************************************************************************
    ID: 164b6e42-3978-4884-8112-d9b917150091; Code: 3005; Occurrence: 6; Sequence: 92
    ------------------------------------------------------------------------------------
     
    Application information:
        Machine name:
        OS Version: Microsoft Windows NT 5.2.3790 Service Pack 2
        Product Version: 3.5.1747.4
        Application Path:
        Debug: True
     
    Process information:
        Process ID: 4488
        Process Name: w3wp
     
    Request information:
        Request URL: /tech.aspx
        Rewrite URL: http://***/tech.aspx
        Url Referrer:   Is Authenticated: False
        Authentication Type:
        User:
        User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
        User Address: *.*.*.*
     
    Variables:
        SF_Crawler: False
        AspSessionIDManagerInitializeRequestCalled: True
        Sitefinity.UrlChahged: False
        cmspageid: 2cf4b753-e01f-4575-8ea2-f2918abd3209
        CmsHttpRequest: /tech.aspx
        RadControlRandomNumber: 0
        _!TelerikVersionStampRendered: True
        cmsurlcontext: Tech
     
    - L0 -------------------------------------------------------------------------------
     
    Exception Type: System.InvalidOperationException
     
    Message: An attempt was made to reference a CacheDependency object from more than one Cache entry.
     
    Source: System.Web
     
    Stack Trace:
       at System.Web.Caching.CacheEntry.MonitorDependencyChanges()
       at System.Web.Caching.CacheSingle.UpdateCache(CacheKey cacheKey, CacheEntry newEntry, Boolean replace, CacheItemRemovedReason removedReason, Object& valueOld)
       at System.Web.Caching.CacheMultiple.UpdateCache(CacheKey cacheKey, CacheEntry newEntry, Boolean replace, CacheItemRemovedReason removedReason, Object& valueOld)
       at System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic, String key, Object value, CacheDependency dependencies, DateTime utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace)
       at System.Web.Caching.Cache.Insert(String key, Object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration)
       at Telerik.Caching.MemoryCachingProvider.Insert(String key, Object value, CacheDependency dependencies, Int32 duration, Boolean slidingExpiration)
       at Telerik.Caching.MemoryCachingProvider.Insert(String key, Object value, CacheDependency dependencies)
       at Telerik.Caching.CachingManager.Insert(String key, Object value, CacheDependency dependencies)
       at Telerik.Cms.Web.UrlHelper.AddPageToCache(String url, String content, CacheDependency dependencies)
       at Telerik.Cms.Web.InternalPage.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    ------------------------------------------------------------------------------------

    Here is an occurrence from the log file.
  10. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    03 Feb 2010
    Link to this post
    Hi Jim Aderhold,

    Thank you for the stack trace. This reveals the mystery. 

    The problem is in the memoryCache provider, which unfortunately is fixed in later versions, but we can provide you with a workaround at this time for your version. If you do not wish to upgrade, then you should disable the cache for this page. 

    We are sorry for the inconvenience.

    Regards,
    Georgi
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  11. Jim Aderhold
    Jim Aderhold avatar
    48 posts
    Registered:
    29 Feb 2004
    17 Feb 2010
    Link to this post
    Is there anyway that we can get a fix for 3.5? We just released the site and the custom controls were built on 3.5.
  12. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Feb 2010
    Link to this post
    Hello Jim Aderhold,

    Apologies, I meant to say that we cannot provide you with a workaround for SF 3.5 at this time. Disabling the cache on this page would still be a solution though. 

    Once again sorry for the inconvenience. 

    Best wishes,
    Georgi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
12 posts, 0 answered