Click to See Complete Forum and Search --> : Rookie Question about Cache Object


bryker
July 16th, 2002, 06:11 PM
I should say up front: I'm brand-new to .NET all things webbish, in terms of development.

All around the ASP.NET world, at pages like these:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp04262001.asp

http://www.devx.com/premier/mgznarch/vbpj/2001/11nov01/an0111/an0111-1.asp

you'll see folks refer to a "Cache" object. I don't mean that they declare a variable of type System.Web.Caching.Cache, they just use some Cache object which they always seem to have handy. Take this MSDN code snippet:

>Dim dependency as new CacheDependency(Server.MapPath("product.xml"))
>Cache.Insert("ProductData", dom, dependency)

Okay, well, I can't do that in my Web Service. I can't just refer to some always-present Cache object and start using it. What's wrong with me? Is there some library I haven't referenced?

If I try to do a "Cache.Insert", I immediately get a syntax error: "Cache' is a type in 'Caching' and cannot be used as an expression.". And if I try do do something as stupid as this:

oMyCache = New System.Web.Caching.Cache()

then I get a runtime error (SoapException) from system.web.services.dll about how "Object reference not set to an instance of an object".

How are you guys--everyone on the planet except me, apparently--able to instantly use this elusive Cache object?

Thanks very, very much in advance.