Why does the EntLib caching application block use the wrong configuration file

When I try to use code that uses the corporate library caching block, I get the following error:

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

This section is in my app.config file for this particular assembly. If I copy the file to the unit test assembly, which uses the above code, everything will work. Is there a way I can get it to use the application configuration that exists in the specified library, so I don’t need to duplicate it in every assembly that uses it?

+3
source share
2 answers

Yes.

Select the app.config file, which will be your main configuration file (the one in the project of the main executable application will be a good choice).

Now go to another project (unit test project). Right-click and select Add Existing Item. Specify the main app.config file and add using the "As a link" option :

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

Now you just need to manage one app.config file, and other projects will link to this file.

Option 2: If you do not want to control which configuration file is used by the corporate library to cache the configuration, use:

var fileSource = new FileConfigurationSource(configFilePath);
var factory = new CacheManagerFactory(fileSource);
ICacheManager manager = factory.CreateDefault();
+2
source

dll, IDE ( ..), . ; yourexename.config. - , entlib.

, AppDomain, . , , , (. configSource ), ( ) ( unit test ).

+1

Source: https://habr.com/ru/post/1732803/


All Articles