Nicolas Dorier
Nicolas Dorier

Reputation: 7465

How do you use ASP.NET Cache object in a not ASP.NET application?

I'd like to use System.Web.Caching.Cache object in my application, but this code throws a NullReferenceException.

Cache cache = new Cache();
cache["key"] = new object();

Any ideas ?

Update

HttpRuntime.Cache solve my problem but does somebody has a solution to use multiple instance of cache in my application ?

Upvotes: 4

Views: 467

Answers (2)

Canavar
Canavar

Reputation: 48088

Enterprise Library Caching Application Block might help you. It works fine for Windows applications as well as ASP.NET Applications.

Upvotes: 2

Greg Beech
Greg Beech

Reputation: 136627

Use the HttpRuntime.Cache static property; it works fine.

Upvotes: 4

Related Questions