![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, ill try and make this as brief as i can, i am having some problems with caching with VS.NET 2005 and .NET 2.0. i have the following code which loads the content of an xml file into a hashtable and then caches the hashtable for later use. private static void LoadResource(ResourceManagerType resourceType, Hashtable target, String language, String cacheKey) { String filePath = HttpContext.Current.Server.MapPath("~/Themes/Languages/" + language + "/{0}"); switch (resourceType) { case ResourceManagerType.String: filePath = String.Format(filePath, "Resources.xml"); break; case ResourceManagerType.Image: filePath = String.Format(filePath, "Images.xml"); break; } CacheDependency dp = new CacheDependency(filePath); XmlDocument d = new XmlDocument(); try { d.Load(filePath); } catch { return; } foreach (XmlNode n in d.SelectSingleNode("root").ChildNodes) { if (n.NodeType != XmlNodeType.Comment) { switch (resourceType) { case ResourceManagerType.String: case ResourceManagerType.Image: if (target[n.Attributes["name"].Value] == null) { target.Add(n.Attributes["name"].Value, n.InnerText); } else { target[n.Attributes["name"].Value] = n.InnerText; } break; } } } DateTime cacheUntil; if (language == EnigmaConfiguration.GetConfig().DefaultLanguage) { cacheUntil = DateTime.MaxValue; } else { cacheUntil = DateTime.Now.AddHours(1); } HttpContext.Current.Cache.Insert(cacheKey, target, dp, cacheUntil, TimeSpan.Zero); // this sometimes fails to insert into the cache and the resultant check for cacheKey in the cache returns null } My question is simply this, is there a problem with cacheing in .net 2.0, it seems that on some occasions cache.Insert(...) fails to insert the data into the cache and result in a null reference exception. I never had this problem before in .net 1.1 or .net 1.0. Any help would be appreciated Regards Neil |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |