Corporate library does not find source code files in asp.net application

I have configuration files in the base directory, they are always installed in Content / copy, in my asp.net web project, and when the application starts, it says that it cannot find the files.

<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source"> <sources> <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" /> <!--<add name="Logging File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="AutomatorConsoleFileFullLogging.config" />--> <add name="Logging File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="Logging Configs\AutomatorConsoleFileFullLogging.config" /> <add name="Exception Handling Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="ExceptionHandling.config" /> <add name="Policy Injection Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="PolicyInjection.config" /> </sources> <redirectSections> <add sourceName="Exception Handling Source" name="exceptionHandling" /> <add sourceName="Logging File Source" name="loggingConfiguration" /> <add sourceName="Policy Injection Configuration Source" name="Policy Injection Settings" /> </redirectSections> 

+4
source share
2 answers

I assume you get a message similar to: System.IO.FileNotFoundException: Cache.config configuration file not found.

From your configuration, I see that you are using Enterprise Library 5.0 (build 414). There is a problem with relative paths and FileConfigurationSource in ASP.NET in this version.

Microsoft Enterprise Library 5.0 Optional Update 1 (build 505) fixes this problem, so if you are coming with the latest version, then the problem should be resolved.

Or you can modify the configuration file to use absolute paths. Another solution is to create your own FileConfigurationSource, which will resolve the path correctly. You can find the source in the comments of the problem report .

+2
source
  <!--<add name="Logging File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="AutomatorConsoleFileFullLogging.config" />--> <add name="Logging File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" filePath="Logging Configs\AutomatorConsoleFileFullLogging.config" /> 

Why?

Uncomment the first tag, comment out the second tag. I think this should solve your problem?

0
source

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


All Articles