why does cache depends on configuration? using cache in Programming time

Topics: Caching Application Block
Jan 15, 2007 at 8:47 AM

c# .net 2

I would like to use enterpriseLibrary cache in module which is being executed from the vs2005.

My problem is that the cache automatically looks for definitions in the executable file configuration (ie c:\program files\...\devenv.exe.config).

How can i create CacheManager instance not from the configuration file?

Many thanks,
Jan 15, 2007 at 2:01 PM
By default, Enterprise Library uses the web.config or app.config of your application to look for configuration information for the Caching Application Block. This tells the block which CacheManagers are available and used by default as well as the cache stores and settings they use.

It is a lot of information to manipulate programmatically, which is why it is rather ideal to put it in an external configuration. An external configuration is also ideal when you want to change some settings and the cache stores on-the-fly without changing the source code of your application and re-compiling it.

If you still want to programmatically create the caching environment, I recommend reading the documentation which is pretty detailed about how the application block was designed and how to modify and extend it. You can also look at the source code and quickstarts to get a good idea of how to programmatically create the items without needing an external configuration file.




David Hayden
Microsoft MVP C#