At a glance your code snippet looks fine (as you said, it was working before). Usually the index errors are do to with using array, but your code doesn't do anything with those... so not sure what the cause might be. :-(
Error Loading Razor Script (file: Header Image) Index was outside the bounds of the array. at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias) at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias) at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result) at CallSite.Target(Closure , CallSite , Object ) at ASP._Page_macroScripts_HeaderImage_cshtml.Execute() in c:\inetpub\EBE\macroScripts\HeaderImage.cshtml:line 1 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
We've just had a very similar problem to this. In happened last night. The site in question gets many visitors and there the number of requests caused the website to go down. We restarted the app pool this morning and it resolved the issue. The site was down for 5 hours. The is built in v4.9.1
The site is a pretty high profile site for us so any help would be greatly appreciated so we can find the problem and fix. The error message in the log table is:
(Referred by: ): System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias) at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at WCSiteMaster.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Same thing is happening to my high-activity site - scheduled app pool recycles sometimes cause Umbraco to have internal issues and I get the same exception. Note an application pool recycle normally fixes it as it seems to be a thread race-condition issue. I'm running 4.8.0 (and Ben is running 4.9.1) but I can see the same code causing the issue is still there in 4.11.5.
Great to find this, I thought I'd been going mad. Adam, I'm having the exact same problem, although our site isn't particuarily high traffic. As you say, it only happens when the app pool recycles, but I can go days/weeks without it happening, then it'll pop up again.For reference, I'm running 4.11.1.
As above, I'm getting the "Index was out of bounds" error repeatedly until I manually recycle the app pool which fixes it.
Interestingly enough I'm still experiencing this issue after disabling all caching on all macros completely (assuming setting to 0 seconds does this). I do however have pretty substantial "custom" caching of DB calls etc. but I wouldn't have thought this would have any effect on the issue at hand? I guess there is more caching goign on in Umbraco itself and not just related to the macros.
Great to see a patch fix is on it's way though - eager to install and monitor it's effect.
Just had this same issue on a 4.7.2 site. All macros were failing but content was rendering. So it could not have been a database issue. We are running Doc Cart and some light eCommerce on this site and it does get quite a bit of traffic. Recyling the app pool resolved this right away. I wonder if upgrading this site would prevent this from happening again?
Not sure exactly what upgrade it was that fixed it (it was a while ago I had it), but my site was running 4.11.1, and was upgraded to 4.11.7 and it erradicated the problem completely. Definately would suggest an upgrade if you can.
Interestingly there are other contour forms on the same instance that were still up and running fine while this was erroring out in the front end and the contour admin tool.
But the same issue occurs for me every so often on another 4.7 site. Usually occurs after a Windows Update and system reboot. All the macros will error out on the site but the rest of the site functions fine.
In both these cases, an application pool recycle brings everthing back to life...
Any insight on what is up here would be great... a little disconcerning when these crashes are intermittant.
Razor Script Index was outside the bounds of the array
Since some days we are getting the following issue for some of our razor macros (not all)
Index was outside the bounds of the array
Any idea how this can happen?
Hi dominik,
Are you able to provide an example code snippet? We might be able to pinpoint the cause of the error.
Thanks, Lee.
Hi Lee,
Here is one of the script which is creating this issue.
The funny thing is that the same code was working before and is working on another instance.
@if(@Model.headerImage.ToString() != "") {
<div id="top-" style="background:red;background-image: url(@Model.Media("headerImage","umbracoFile"));background-repeat: no-repeat;"></div>
} else if(@Model.menuClass.ToString() != "") {
<div id="[email protected]"> </div>
} else {
<div id="top-service-corner"> </div>
}
Hi dominik,
At a glance your code snippet looks fine (as you said, it was working before). Usually the index errors are do to with using array, but your code doesn't do anything with those... so not sure what the cause might be. :-(
- Lee
is this an MsSQL problem?
THe stack trace is showing the following:
Error Loading Razor Script (file: Header Image) Index was outside the bounds of the array. at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias)
at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias)
at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result)
at CallSite.Target(Closure , CallSite , Object )
at ASP._Page_macroScripts_HeaderImage_cshtml.Execute() in c:\inetpub\EBE\macroScripts\HeaderImage.cshtml:line 1
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.WebPages.WebPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
HI Lee,
Now the macros are working again without touching any file.
For me it looks like a database problem but how can we ensure that this will not happen any more in the future?
Thanks
Hi
We've just had a very similar problem to this. In happened last night. The site in question gets many visitors and there the number of requests caused the website to go down. We restarted the app pool this morning and it resolved the issue. The site was down for 5 hours. The is built in v4.9.1
The site is a pretty high profile site for us so any help would be greatly appreciated so we can find the problem and fix. The error message in the log table is:
Thanks
Ben
Same thing is happening to my high-activity site - scheduled app pool recycles sometimes cause Umbraco to have internal issues and I get the same exception. Note an application pool recycle normally fixes it as it seems to be a thread race-condition issue. I'm running 4.8.0 (and Ben is running 4.9.1) but I can see the same code causing the issue is still there in 4.11.5.
I've raised U4-1874 at http://issues.umbraco.org/issue/U4-1874
Great to find this, I thought I'd been going mad. Adam, I'm having the exact same problem, although our site isn't particuarily high traffic. As you say, it only happens when the app pool recycles, but I can go days/weeks without it happening, then it'll pop up again.For reference, I'm running 4.11.1.
As above, I'm getting the "Index was out of bounds" error repeatedly until I manually recycle the app pool which fixes it.
Yeah, a race condition is just that - can happy anytime. Please vote for the issue at http://issues.umbraco.org/issue/U4-1874 :-)
Thanks.
Interestingly enough I'm still experiencing this issue after disabling all caching on all macros completely (assuming setting to 0 seconds does this). I do however have pretty substantial "custom" caching of DB calls etc. but I wouldn't have thought this would have any effect on the issue at hand? I guess there is more caching goign on in Umbraco itself and not just related to the macros.
Great to see a patch fix is on it's way though - eager to install and monitor it's effect.
Just had this same issue on a 4.7.2 site. All macros were failing but content was rendering. So it could not have been a database issue. We are running Doc Cart and some light eCommerce on this site and it does get quite a bit of traffic. Recyling the app pool resolved this right away. I wonder if upgrading this site would prevent this from happening again?
Not sure exactly what upgrade it was that fixed it (it was a while ago I had it), but my site was running 4.11.1, and was upgraded to 4.11.7 and it erradicated the problem completely. Definately would suggest an upgrade if you can.
I just had this issue occur on a Contour 3.0.14 form in Umbraco 6.1.6.
The error is: "Index was outside the bounds of the array"
<%# RenderFieldPreview(((Umbraco.Forms.Core.Field)Container.DataItem)) %>
Interestingly there are other contour forms on the same instance that were still up and running fine while this was erroring out in the front end and the contour admin tool.
But the same issue occurs for me every so often on another 4.7 site. Usually occurs after a Windows Update and system reboot. All the macros will error out on the site but the rest of the site functions fine.
In both these cases, an application pool recycle brings everthing back to life...
Any insight on what is up here would be great... a little disconcerning when these crashes are intermittant.
Jamie
is working on a reply...