The part of the code in CMS that I use (DNN) throws the following exception:
"The index was outside the array.
Using the word stacktrace:
at System.Collections.Generic.List`1.Contains(T item)
This is a problem that occurs only occasionally (I suspect that it has something to do with cache failure) and only in production. This means that I cannot play it sequentially. What interests me most is how this can happen.
How is it possible that a call to βContainsβ invokes an index outside the bounds?
Additional Information
The code that calls Contains works as follows (I simplified the code to make important parts more readable. Links lead to exact classes and sheets)
CustomUrlDictController.cs
List<int> urlPortals;
var cc = new CacheController();
cc.GetFriendlyUrlIndexFromCache(out urlPortals);
var boolean = urlPortals.Contains(portalId);
CacheController.cs
void GetFriendlyUrlIndexFromCache(out List<int> urlPortals)
{
urlPortals = null;
object rawPortals = DataCache.GetCache(UrlPortalsKey);
if (rawPortals != null)
{
urlPortals = (List<int>)rawPortals;
}
}
DataCache ( 1 , 2 )
object GetCache(string CacheKey)
{
return Cache[cacheKey];
}
InnerMessage:Index was outside the bounds of the array.
InnerStackTrace:
at System.Collections.Generic.List`1.Contains(T item)
at DotNetNuke.Entities.Urls.CustomUrlDictController.FetchCustomUrlDictionary(Int32 portalId, Boolean forceRebuild, Boolean bypassCache, FriendlyUrlSettings settings, SharedDictionary`2& customAliasForTabs, Guid parentTraceId)
at DotNetNuke.Entities.Urls.TabPathHelper.GetTabPath(TabInfo tab, FriendlyUrlSettings settings, FriendlyUrlOptions options, Boolean ignoreCustomRedirects, Boolean homePageSiteRoot, Boolean isHomeTab, String cultureCode, Boolean isDefaultCultureCode, Boolean hasPath, Boolean& dropLangParms, String& customHttpAlias, Boolean& isCustomPath, Guid parentTraceId)
at DotNetNuke.Entities.Urls.AdvancedFriendlyUrlProvider.ImproveFriendlyUrlWithMessages(TabInfo tab, String friendlyPath, String pageName, PortalSettings portalSettings, Boolean ignoreCustomRedirects, FriendlyUrlSettings settings, List`1& messages, Boolean cultureSpecificAlias, Guid parentTraceId)
at DotNetNuke.Entities.Urls.AdvancedFriendlyUrlProvider.ImproveFriendlyUrl(TabInfo tab, String friendlyPath, String pageName, PortalSettings portalSettings, Boolean ignoreCustomRedirects, Boolean cultureSpecificAlias, FriendlyUrlSettings settings, Guid parentTraceId)
at DotNetNuke.Entities.Urls.AdvancedFriendlyUrlProvider.FriendlyUrlInternal(TabInfo tab, String path, String pageName, String portalAlias, PortalSettings portalSettings)
at DotNetNuke.Entities.Urls.AdvancedFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings portalSettings)
at DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings settings)
at DotNetNuke.Common.Globals.NavigateURL(Int32 tabID, Boolean isSuperTab, PortalSettings settings, String controlKey, String language, String pageName, String[] additionalParameters)
at DotNetNuke.Common.Globals.NavigateURL(Int32 tabID, String controlKey, String[] additionalParameters)
at Ventrian.SimpleGallery.RandomPhoto.GetAlbumUrl(String albumID)
at Ventrian.SimpleGallery.RandomPhoto.BindPhoto(PlaceHolder phPhoto, PhotoInfo objPhoto)
at Ventrian.SimpleGallery.RandomPhoto.dlGallery_OnItemDataBound(Object sender, DataListItemEventArgs e)
at System.Web.UI.WebControls.DataList.OnItemDataBound(DataListItemEventArgs e)
at System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem)
at System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at Ventrian.SimpleGallery.RandomPhoto.Page_Load(Object sender, EventArgs e)