Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the EntLib Caching Application Block using the wrong configuration file

When I try and use code that makes use of the Enterprise Library Caching Block I get the following error:

The "cachingConfiguration" section is not available in the supplied configuration source.

The section is in my app.config file for that particular assembly though. If I copy the file into the unit test assembly that makes use of the afore mentioned code everything works. Is there any way that I can force it to use the app config that exists in the referenced library so I don't need to duplicate it in every assembly that makes use of it?

like image 616
LaserJesus Avatar asked Dec 21 '25 04:12

LaserJesus


1 Answers

Yes.

Select an app.config file to be your master config file (a good choice would be the one in the project of the main application executable).

Now go to your other project (fx. the unit test project). Right-click and select Add Existing Item. Point to the master app.config file and add using the "As link" option:

Add as link http://blog.codevelop.dk/pics/AddAsLink.png

Now you only need to manage one app.config file, and the other projects will 'reference' this file.

Option 2: If you wan't to control what config file the Enterprise Library uses for caching configuration, use:

var fileSource = new FileConfigurationSource(configFilePath);
var factory = new CacheManagerFactory(fileSource);
ICacheManager manager = factory.CreateDefault();
like image 185
peter_raven Avatar answered Dec 22 '25 18:12

peter_raven