[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Manso

3/6/2006 12:10:00 PM

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 Answers

Alvin Bruney [ASP.NET MVP]

3/6/2006 6:24:00 PM

0

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@discussions.microsoft.com> wrote in message
news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E@microsoft.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
>


Manso

3/6/2006 8:42:00 PM

0

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@discussions.microsoft.com> wrote in message
> news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E@microsoft.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
> >
>
>
>

Alvin Bruney [ASP.NET MVP]

3/6/2006 9:26:00 PM

0

> 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@discussions.microsoft.com> wrote in message
news:42F9955B-DCD7-4807-9C53-A276A58302B6@microsoft.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@discussions.microsoft.com> wrote in message
> > news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E@microsoft.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
> > >
> >
> >
> >


Manso

3/6/2006 9:40:00 PM

0

I posted this on a separate thread becuase it's not related to HttpRuntime

http://msdn.microsoft.com/newsgroups/managed/default.aspx?dg=microsoft.public.dotnet.framework.aspnet.caching&mid=21114551-f902-42ad-ac5b-c3df5d941d95&...

Thanks for your help.

- Manso

"Alvin Bruney - ASP.NET MVP" wrote:

> > 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@discussions.microsoft.com> wrote in message
> news:42F9955B-DCD7-4807-9C53-A276A58302B6@microsoft.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@discussions.microsoft.com> wrote in message
> > > news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E@microsoft.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
> > > >
> > >
> > >
> > >
>
>
>