我在窗口应用程序中从 app_config 读取连接字符串时收到此异常“配置系统无法初始化”
string con = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
在输入以下行后在这一行
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
在 AssemblyInfo.cs 中。如果我从 Assemblyinfo.cs 中删除这一行,那么毫无异常(exception)我将添加此程序集用于记录目的
最佳答案
我不确定,但如果您使用 VSTO 进行 MS Office 加载项开发,那么下面的帖子可能会对您有所帮助。
Why is log4net not recognized in configuration file?
您还需要在部分块中添加 log4net
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
关于c# - 配置系统在 log4net 中初始化失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8475366/