【问题标题】:Configuration system failed to initialize in log4net配置系统在 log4net 中初始化失败
【发布时间】:2012-01-18 12:12:54
【问题描述】:

我在窗口应用程序中从 app_config 读取连接字符串时收到此异常“配置系统无法初始化”

string con = ConfigurationSettings.AppSettings["ConnectionString"].ToString();

输入以下行后在此行上

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

在 AssemblyInfo.cs 中。如果我从 Assemblyinfo.cs 中删除此行,那么我将毫无例外地添加此程序集以用于记录目的

【问题讨论】:

    标签: c# .net log4net connection-string log4net-configuration


    【解决方案1】:

    这是一个 .NET 问题,而不是 log4net 问题。您的 app.config 文件未加载。请参阅Configuration System Failed to Initialize 以获得真正问题的良好答案。

    【讨论】:

      【解决方案2】:

      我不确定,但如果您使用 VSTO 进行 MS Office 插件开发,那么下面的帖子可能会对您有所帮助。

      Why is log4net not recognized in configuration file?

      您还需要在部分块中添加 log4net

      <configSections>
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> 
      </configSections>
      

      【讨论】:

        猜你喜欢
        • 2011-09-20
        • 1970-01-01
        • 1970-01-01
        • 2012-04-23
        • 2014-09-28
        • 1970-01-01
        相关资源
        最近更新 更多