输入初始化错误 [英] Type initialization error
本文介绍了输入初始化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误
'System.Windows.Application'的类型初始值设定项引发异常$ p当我在app.config文件中有以下内容时,$ p>
。这是一个WPF应用程序。
<? xml version = 1.0 encoding = utf-8 ? >
< 配置 >
< log4net >
< appender name = RollingFileAppenderV1 type = < span class =code-keyword> log4net.Appender.RollingFileAppender >
< ; file type < span class =code-keyword> = log4net.Util.PatternString < span class =code-attribute> value = xxxzzzlog.txt / >
< < span class =code-leadattribute> appendToFile value = true < span class =code-keyword> / >
< rollingStyle value = 大小 / >
< maxSizeRollBackups value = 50 / >
< maximumFileSize 值 = 100KB / >
< staticLogFileName value = true / >
< countDirection < span class =code-attribute> value = 1 / >
< 布局 type = log4net.Layout.PatternLayout >
< param 名称 = ConversionPattern value = [%d {yyyy-MM-dd hh:mm:ss}] - [%-5p] - %m%n / < span class =code-keyword>>
< / layout >
< / appender >
< root >
< level value = 所有 / >
< appender-ref ref = RollingFileAppenderV1 / >
< < span class =code-leadattribute> / root >
< / log4net >
< 启动 >
< supportedRuntime version = v4.0 sku = 。NETFramework,Version = v4.5 / >
< / startup >
< / configuration >
我还是找不到这个配置文件有什么问题。没有log4net配置它工作正常。任何评论都非常感谢。
解决方案
我找到了解决方案,我错过了log4net的配置。以下需要在log4net标记之前的app.config中。
< ; configsections >
< section name = log4net type = log4net.Config.Log4NetConfigurationSectionHandler,Log4net < span class =code-attribute> / >
< / configsections >
I got the following error
The type initializer for 'System.Windows.Application' threw an exception
when I've the following content in app.config file. This is a WPF application.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<appender name="RollingFileAppenderV1" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="xxxzzzlog.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="50"/>
<maximumFileSize value="100KB"/>
<staticLogFileName value="true"/>
<countDirection value="1"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d{yyyy-MM-dd hh:mm:ss}] - [%-5p] – %m%n"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="RollingFileAppenderV1"/>
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Still I couldn't find what's wrong with this config file. Without the log4net configuration it works fine. Any comments really appreciate.
解决方案 I Found the solutions, I've miss the configuration for log4net. Following need to be in the app.config just before the log4net tag.
<configsections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
</configsections>
这篇关于输入初始化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文