![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET application. This callback function will access the cache and I'm using HttpRuntime.Cache to intert an item to the cache with a file dependecy. Every now and then the cache item requested is Null and I can't seem to work out when it happens. Are there any limitation on HttpRuntime vs. HttpContext.Current cache? We've been using HttpContext.Current for quite some time without any problems but when switching to HttpRuntime the items don't stick in the cache anymore. Thanks, Manso |
#3
| |||
| |||
|
|
the two both map to the same object. what most likely is happening is that your cache is beign scavenged by the OS. There's no guarantee made by the run-time that your cache objects will be available by the way so you should not code with that assumption. Instead, you should test the cache before u use it and replenish it as needed. -- Regards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ www.lulu.com/owc Forth-coming VSTO.NET - Wrox/Wiley 2006 ------------------------------------------------------- "Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com... hi, I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET application. This callback function will access the cache and I'm using HttpRuntime.Cache to intert an item to the cache with a file dependecy. Every now and then the cache item requested is Null and I can't seem to work out when it happens. Are there any limitation on HttpRuntime vs. HttpContext.Current cache? We've been using HttpContext.Current for quite some time without any problems but when switching to HttpRuntime the items don't stick in the cache anymore. Thanks, Manso |
#4
| |||
| |||
|
|
Does anyone know how we can troubleshoot this? I'm starting to miss the old VB function "Add watch and break when variable X changes"... |
|
Thanks for your reply. There is a difference on how the two work. I have an isolated case where I simply changed from HttpContext.Current.Cache to HttpRuntime.Cache with a file dependency and the one with HttpRuntime gets reset. Not all the time but sporadically. The code is located in a separate assembly being referenced from a web project. When I change back it works well again. Does anyone know how we can troubleshoot this? I'm starting to miss the old VB function "Add watch and break when variable X changes"... Thanks, Manso "Alvin Bruney - ASP.NET MVP" wrote: the two both map to the same object. what most likely is happening is that your cache is beign scavenged by the OS. There's no guarantee made by the run-time that your cache objects will be available by the way so you should not code with that assumption. Instead, you should test the cache before u use it and replenish it as needed. -- Regards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ www.lulu.com/owc Forth-coming VSTO.NET - Wrox/Wiley 2006 ------------------------------------------------------- "Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com... hi, I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET application. This callback function will access the cache and I'm using HttpRuntime.Cache to intert an item to the cache with a file dependecy. Every now and then the cache item requested is Null and I can't seem to work out when it happens. Are there any limitation on HttpRuntime vs. HttpContext.Current cache? We've been using HttpContext.Current for quite some time without any problems but when switching to HttpRuntime the items don't stick in the cache anymore. Thanks, Manso |
#5
| |||
| |||
|
|
Does anyone know how we can troubleshoot this? I'm starting to miss the old VB function "Add watch and break when variable X changes"... You shouldn't. .NET has more powerful monitoring tools. One simple approach is to set a conditional breakpoint on th value of the cache object. Another approach is to set the break on all exceptions. If you can reproduce this at will, i'd be interested in looking at some code. -- Regards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ www.lulu.com/owc Forth-coming VSTO.NET - Wrox/Wiley 2006 ------------------------------------------------------- "Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message news:42F9955B-DCD7-4807-9C53-A276A58302B6 (AT) microsoft (DOT) com... Thanks for your reply. There is a difference on how the two work. I have an isolated case where I simply changed from HttpContext.Current.Cache to HttpRuntime.Cache with a file dependency and the one with HttpRuntime gets reset. Not all the time but sporadically. The code is located in a separate assembly being referenced from a web project. When I change back it works well again. Does anyone know how we can troubleshoot this? I'm starting to miss the old VB function "Add watch and break when variable X changes"... Thanks, Manso "Alvin Bruney - ASP.NET MVP" wrote: the two both map to the same object. what most likely is happening is that your cache is beign scavenged by the OS. There's no guarantee made by the run-time that your cache objects will be available by the way so you should not code with that assumption. Instead, you should test the cache before u use it and replenish it as needed. -- Regards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] The Microsoft Office Web Components Black Book with .NET Now Available @ www.lulu.com/owc Forth-coming VSTO.NET - Wrox/Wiley 2006 ------------------------------------------------------- "Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com... hi, I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET application. This callback function will access the cache and I'm using HttpRuntime.Cache to intert an item to the cache with a file dependecy. Every now and then the cache item requested is Null and I can't seem to work out when it happens. Are there any limitation on HttpRuntime vs. HttpContext.Current cache? We've been using HttpContext.Current for quite some time without any problems but when switching to HttpRuntime the items don't stick in the cache anymore. Thanks, Manso |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |