gpt4 book ai didi

asp.net - 企业库在 ASP.NET 应用程序中找不到配置源文件

转载 作者:行者123 更新时间:2023-12-02 21:18:31 25 4
gpt4 key购买 nike

我的配置文件位于我的 asp .net Web 项目的基本目录中,始终设置为 Content/copy,当应用程序运行时,它说找不到文件。

<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。

从您的配置中我可以看到您正在使用 Enterprise Library 5.0(Build 414)。有一个issue在该版本中,ASP.NET 中具有相对路径和 FileConfigurationSource。

Microsoft Enterprise Library 5.0 Optional Update 1 (版本 505)已修复此问题,因此如果您使用最新版本,则该问题应该得到解决。

或者您可以更改配置文件以使用绝对路径。另一个修复方法是创建您自己的 FileConfigurationSource 来正确解析路径。您可以在 comments of the issue report 中找到源代码.

关于asp.net - 企业库在 ASP.NET 应用程序中找不到配置源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9333215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com