企业库在asp.net应用程序中找不到配置源文件 [英] Enterprise Library not finding config source files in asp.net app

查看:53
本文介绍了企业库在asp.net应用程序中找不到配置源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的配置文件在基本目录中,在我的asp .net Web项目中始终设置为内容/复制",当应用程序运行时,它说找不到文件.

I have my config files in the base directory, set to Content/copy always, in my asp .net web project and when the app runs, it says 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>

推荐答案

我假设您收到类似以下消息:System.IO.FileNotFoundException:找不到配置文件cache.config.

I assume you are getting a message similar to: System.IO.FileNotFoundException: The configuration file cache.config could not be found.

从您的配置中,我可以看到您正在使用Enterprise Library 5.0(内部版本414).该版本中有一个问题,其中包含相对路径和ASP.NET中的FileConfigurationSource.

From your configuration I can see that you are using Enterprise Library 5.0 (Build 414). There is an issue in that release with relative paths and FileConfigurationSource in ASP.NET.

Microsoft Enterprise Library 5.0可选更新1 (内部版本505))已解决此问题,因此,如果您使用最新版本,则应解决该问题.

Microsoft Enterprise Library 5.0 Optional Update 1 (build 505) has this issue fixed so if you go with the latest version then the issue should be resolved.

或者您可以更改配置文件以使用绝对路径.另一个解决方法是创建自己的FileConfigurationSource,以正确解析路径.您可以在问题报告的评论中找到源.

Or you could change the config file to use absolute paths. Another fix would be to create your own FileConfigurationSource that correctly resolves the path. You can find source in the comments of the issue report.

这篇关于企业库在asp.net应用程序中找不到配置源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆