+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / stack overflow when adding a ContentView control

stack overflow when adding a ContentView control

13 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    05 May 2009
    Link to this post
    I created a custom content view control that inherits from, of course ContentView.   I added it to a control template from a pluggable module I wrote, patterned after the sample product module, and that is also based on the ContentView control.

    When I do this, I get a stack overflow error.  At first I thought I'd done something really wrong in my code, but even if I comment out all the code in the custom content view control, the mere fact of having it in the control template causes this.

    Is there a workaround? 

    I've noticed other odd behavior from the ContentView control recently.  For example, I haven't figured out a reliable way to have more than one a single page, unless you use a separate page for the single item view, because even if you're viewing a single item from one content view control, the others display their list.

    Anyway, I'd rather use the ContentView approach rather than write a user control based on the old method of filtering content, but the stack overflow is a problem.

    Regards,
    Mike Sharp
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    05 May 2009
    Link to this post
    Hello Mike,

    Could you please show us the stack trace? We had a problem with a memory leak caused in one of .NET classes, and we have workaround it in the 3.5 version.
    Which is the version that you use?

    Kind regards,
    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.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    05 May 2009
    Link to this post
    I am using SF 3.5 in this project.  I don't actually get a stack trace.  The visual studio JIT debugger launches...but the page itself never completes.  I just get an error dialog:

    "An unhandled exception('<System.StackOverflwException>') ccurred in w3wp.exe

    When I debug, the error is:

    {Cannot evaluate expression because the current thread is in a stack overflow state.}

    Mike
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    08 May 2009
    Link to this post
    Hi Mike,

    The stack overflow exception most probably comes from a recursion somewhere. I am not sure what you are doing in your control though - could you please check if you have any recursion that makes too much (endless) loops?

    We can take a look at the control anyway, if you are willing to send it to us.

    Thank you for your cooperation.

    Kind regards,
    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. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    13 May 2009
    Link to this post
    I gave up on this approach, since it seemed there is something fundamentally wrong with putting a control based on ContentView inside of another ContentView control. 

    The stack overflow even happened when I placed a blank class inheriting from ContentView within the control template used by another content view control.

    Because of time constraints, I ended up creating a regular user control, and the deprecated way of searching/filtering content.

    Regards,
    Mike Sharp

  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    15 May 2009
    Link to this post
    Hello Mike,

    Thank you for the follow up.
    We can review the control that was not working as exptected if you want. Just let us know.

    Kind regards,
    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.
  7. Ryan Ternier
    Ryan Ternier avatar
    32 posts
    Registered:
    24 Nov 2005
    15 Jan 2010
    Link to this post
    You can get a stack overflow if you add multiple controls that include the same JS files.

    Example:

    Control:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ImageLightbox.ascx.cs" Inherits="CustomControls_ImageLightbox" %> 
    <% @ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>  
    <telerik:CssFileLink ID="CssFileLink" FileName="~/Sitefinity/ExternalLibraries/lightbox/css/lightbox.css" Media="screen" runat="server" /> 
    <telerik:JsFileLink ID="PrototypeLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/prototype.js" /> 
    <telerik:JsFileLink ID="ScriptaculousLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/scriptaculous.js?load=effects" /> 
    <telerik:JsFileLink ID="JsFileLink2" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/lightbox.js" /> 
     
    <asp:HyperLink ID="lnkImageLink" runat="server" rel="lightbox" class="vs_lightBoxLink"
        <asp:Image ID="imgLightbox" runat="server" Width="48" Height="48" AlternateText="" class="vs_lightBoxThumb" /> 
    </asp:HyperLink> 
     


    Add 2 or more of those onto 1 page and you'll get the stack overflow. Any way of resolving this?

    .Net 2.0 version - latest SiteInfinityBuild
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Jan 2010
    Link to this post
    Hello Ryan Ternier,

    Thank you for joining the conversation.

    Well the reason for this happening is that each time you include this control you make 4 more requests to resources. At some time you will probably get the stack overflow error, which depends also on how many other controls loading scripts on your pages you have. I have tried this on my machine and loaded 10 of those controls without getting the error, so I guess the point where you get it depends on the environment. Having 10 controls which load those resources really killed the performance of my page.

    In order to prevent issues like this you can try the following. First use RadScriptManager control on your master page instead of the regular ScriptManager control. You can also set it in release mode and enable the script combine. You can find more information on the script manager here: RadScriptManager. The script manager will make RadControls on your page make one call for combined resources.

    Then you can factor out your control's calls for external JS files in the master pages too. This way your controls will work work with the external libraries however the scripts will be loaded only once. This can be done for the external styesheets. See sample bellow:
    <telerik:CssFileLink ID="CssFileLink" FileName="~/Sitefinity/ExternalLibraries/lightbox/css/lightbox.css" Media="screen" runat="server" />
    <telerik:RadScriptManager id="RadScriptManager1" runat="server" ScriptMode="Release" EnableScriptCombine="true" OutputCompression="AutoDetect">
     <Scripts>
         <asp:ScriptReference Path="~/Sitefinity/ExternalLibraries/lightbox/js/prototype.js" ScriptMode="Release"/>
         <asp:ScriptReference Path="~/Sitefinity/ExternalLibraries/lightbox/js/scriptaculous.js?load=effects" ScriptMode="Release" />
         <asp:ScriptReference Path="~/Sitefinity/ExternalLibraries/lightbox/js/lightbox.js" ScriptMode="Release" />                                
     </Scripts>
    </telerik:RadScriptManager>

    Best wishes,
    Radoslav Georgiev
    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.
  9. Ryan Ternier
    Ryan Ternier avatar
    32 posts
    Registered:
    24 Nov 2005
    18 Jan 2010
    Link to this post
    Thanks for the help. However when I do that with my control, I lose the lightbox effect.

    <telerik:JsFileLink ID="PrototypeLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/prototype.js" /> 
    <telerik:JsFileLink ID="ScriptaculousLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/scriptaculous.js?load=effects" /> 
    <telerik:JsFileLink ID="JsFileLink2" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/lightbox.js" /> 
     

    Works, however inside the scriptManager breaks it.

    Will this pose the same issue when I add an image gallery to my site? Because that references the same libraries etc.

    ---Edit
    Even putting these scripts on the masterpage doesn't allow it to work. It will only work if these scripts are in the ASCX file - which is strange. The Masterpage version gives me:
    <script src="/ScriptResource.axd?d=gPt-34AfAh95UmpCupnkYZww24mNbZB0DlhEvWeeYTev7YiwPCLsrZXtVGrXJu--O-yXFB9lRwSmJClMswWebPPMaZ6OTRxkPuE42d5MToc1&amp;t=14a31b75" type="text/javascript"></script> 
     

    When referenceing the JS files, however inside the control I get:
    ><script src="/Sitefinity/ExternalLibraries/lightbox/js/prototype.js" type="text/javascript"></script><script src="/Sitefinity/ExternalLibraries/lightbox/js/scriptaculous.js?load=effects" type="text/javascript"></script><script src="/Sitefinity/ExternalLibraries/lightbox/js/lightbox.js" type="text/javascript"></script> 

  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Jan 2010
    Link to this post
    Hello Ryan Ternier,

    Thank you for getting back to me.

    If you add a lot of image gallery controls you might experience the stack overflow issue, however I am not sure at what point it will break. You can edit the control template for the Image Gallery, located at ~/Sitefinity/Admin/Libraries/Modes/ and then set the control to use this external template through its control editor in the administrative UI. Then you can take the JS links and factor them out in the master pages.

    Best wishes,
    Radoslav Georgiev
    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.
  11. Ryan Ternier
    Ryan Ternier avatar
    32 posts
    Registered:
    24 Nov 2005
    18 Jan 2010
    Link to this post
    Thanks for the reply - sorry I edited my above post before I saw it.

    More or less, adding the script files to the MasterPage isn't working even for my single control. IT seems it's not even loading up the JS properly.

    When looking into it with FireBug / IE developer I don't see any Lightbox references when doing it your way - I only see Lightbox Javascript when putting the JS files in the control itself.
  12. Ryan Ternier
    Ryan Ternier avatar
    32 posts
    Registered:
    24 Nov 2005
    18 Jan 2010
    Link to this post
    Please ignore my ignorance above :)

    It seems the page I was working on got changed to another Template over the weekend - which looked the same... so this is working as intended. Thanks for the help :)
  13. Harish
    Harish avatar
    1 posts
    Registered:
    10 Apr 2012
    16 Apr 2012
    Link to this post
    HI Radoslav Georgiev ,

    we have sitefinity 4.4 and facing stack overflow issue when ever we make certain edits from the CMS log in whereas no exception occur otherwise.Please do let me know how to handle the same and I can share my code if required.

Register for webinar
13 posts, 0 answered