This is a migrated thread and some comments may be shown as answers.

Index was out of range - StyleSheetRegistrar

4 Answers 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kenny
Top achievements
Rank 1
Kenny asked on 07 Nov 2009, 07:25 PM
Hello all,
I've just downloaded the extensions yesterday and trying out some of the featured. My very first attempt, got an "Index was out of range" error whenever I add the StyleSheetRegistrar() or ScriptRegistrar() onto the page, if I comment them out, the page run just fine. I've added the handlers to the web.config, followed the exact steps in the demos, but still having problems.

This is an MVC 2 Preview 2 project, I've also added the MVC Future DLL (Microsoft.Web.Mvc), below is my Site master page:

<%@ Import Namespace="Telerik.Web.Mvc.UI" %> 
 
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title> 
        <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> 
    </title> 
    <%= Html.Telerik().StyleSheetRegistrar() 
        .DefaultGroup(group => group 
            .Add("styles.css") 
            .Add("telerik.common.css") 
            .Combined(true)) 
    %> 
</head> 
<body> 
    <h1> 
        My MVC Application</h1> 
    <div id="logindisplay"
        <% Html.RenderPartial("LogOnUserControl"); %> 
    </div> 
    <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
    <
        Html.Telerik().ScriptRegistrar().Render(); %> 
</body> 
</html> 
 

Any idea what was wrong? Thank you very much,
Kenny.

4 Answers, 1 is accepted

Sort by
0
Kenny
Top achievements
Rank 1
answered on 07 Nov 2009, 07:38 PM
This is the complete error:
Server Error in '/' Application. 
 
Index was out of range. Must be non-negative and less than the size of the collection. 
Parameter name: index 
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  
 
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 
Parameter name: index 
 
Source Error:  
 
 
Line 9:         <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> 
Line 10:    </title> 
Line 11:    <%= Html.Telerik().StyleSheetRegistrar() 
Line 12:        .DefaultGroup(group => group 
Line 13:            .Add("styles.css") 
 
Source File: c:\Users\Kenny V\Documents\Visual Studio 2008\Projects\NotesnhacV3\NotesnhacWeb\Views\Shared\Site.Master    Line: 11  
 
Stack Trace:  
 
 
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 
Parameter name: index] 
   System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +64 
   System.ThrowHelper.ThrowArgumentOutOfRangeException() +15 
   System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +7509166 
   Telerik.Web.Mvc.UI.HtmlHelperExtension.Telerik(HtmlHelper helper) +34 
   ASP.views_shared_site_master.__Render__control2(HtmlTextWriter __w, Control parameterContainer) in c:\Users\Kenny V\Documents\Visual Studio 2008\Projects\NotesnhacV3\NotesnhacWeb\Views\Shared\Site.Master:11 
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256 
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 
   System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +17 
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 
   ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Users\Kenny V\AppData\Local\Temp\Temporary ASP.NET Files\root\db0772e6\9d080a74\App_Web_tiss4o_h.0.cs:0 
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256 
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10 
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29 
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +59 
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266 
 
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 

0
Accepted
Georgi Krustev
Telerik team
answered on 09 Nov 2009, 11:45 AM
Hello Kenny,

Unfortunately I could not reproduce the depicted issue. Please review the attached test project and let me know what the differences are.

Kind regards,
Georgi Krustev
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.
0
Kenny
Top achievements
Rank 1
answered on 09 Nov 2009, 07:45 PM
Hello Georgi,
Thank you very much for taking a look at my problem, I've found out the problem. My web app is a hybrid app (asp.net & mvc), these lines in the web.config file causes Telerik MVC extensions to throw that error. I don't really know why though:

<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> 

and:
<dependentAssembly> 
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> 
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> 
            </dependentAssembly> 

Kenny.


0
Georgi Krustev
Telerik team
answered on 10 Nov 2009, 01:47 PM
Hi Kenny,

Thank you for the clarification of the issue.

Unfortunately I could not reproduce the aforementioned abnormality. I have attached a test project which I created in order to replicate the erroneous behavior. Please review it and let me know if I am missing something.

All the best,
Georgi Krustev
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.
Tags
General Discussions
Asked by
Kenny
Top achievements
Rank 1
Answers by
Kenny
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or