views:

432

answers:

3

I've seen several articles/blog posts that advocate the use of the System.Web.Caching.Cache in applications that are not for the Web, however, the MSDN documentation quite clearly states that

The Cache class is not intended for use outside of ASP.NET applications. It was designed and tested for use in ASP.NET to provide caching for Web applications. In other types of applications, such as console applications or Windows Forms applications, ASP.NET caching might not work correctly.

Is the documentation wrong, or should we really not be using this class? If the latter, what could go wrong? Our platform is Winforms/.NET 3.5.

A: 

documentation is correct, you can not use asp.net cache in windows application.

Cache article.

Syed Tayyab Ali
+1  A: 

You're really not supposed to use it outside of ASP.NET. Here's a good whitepaper on other alternatives, however:

http://msdn.microsoft.com/en-us/library/ms978502.aspx

GuyBehindtheGuy
+4  A: 

Expired or unused Cache objects cannot be automatically removed if the application is not an ASP.NET application. Therefore, if Cache objects are used outside ASP.NET, the system memory that is reserved for the Cache objects is not released. You cannot manually invoke the internal ASP.NET methods to clean up the cache because the methods are marked as internal and intended for internal use. So its your decision to use it in an outside application at your own risk. System.Web.Caching.Cache object

Scott Hanselman has a article post on it for more details

TStamper
It seems to me that the article by Scott Hanselman is in favour of using this in a non-ASP.net application.
Eyvind
Also, the support article you mention talks about .NET 1.0 and 1.1. Could this have changed for 3.5?
Eyvind
its not in favor, it just justified that its not as bad as it seems, and I'm not sure what version of .Net it s, but it was just included to give more info. to the OP
TStamper