我正在进行一个c#项目,而且我一直看到一种奇怪的行为。我启动了我的IDE并在我的wpf项目的XAML中进行了一些更改,运行它,一切正常。但后来我改变了我的app.config中的日志大小并再次运行它,它给了我以下错误:
System.TypeInitializationException was unhandled
Message: An unhandled exception of type 'System.TypeInitializationException' occurred in PresentationFramework.dll
Additional information: The type initializer for 'System.Windows.Application' threw an exception.
我在网上搜索此错误时能够找到的所有内容都是他们的应用配置顺序错误的人(例如配置部分块上方的启动块),但这并不是似乎是我的情况。以下是我的应用配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<log4net>
<root>
<level value="INFO"/>
<appender-ref ref="FileAppender"/>
<appender-ref ref="RollingFileAppender"/>
</root>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="logs/client.log" />
<appendToFile value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/full.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="20MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="ProdCon" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prodip)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=prod))) " />
<dataSource alias="TestCon" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testip)(PORT=1521))(CONNECT_DATA=(SID=test))) " />
</dataSources>
</version>
</oracle.manageddataaccess.client>
</configuration>
我唯一做的就是将<maximumFileSize value="20MB" />
从20MB更改为25MB。我把它改回来了,它仍然抛出了上述错误。
解决此问题的任何方向或去往何处获取更多信息(此异常似乎对任何类型的解释都有点亮,并且在它到达我的任何日志记录之前中断)将不胜感激。
编辑:我只是试图再次运行该项目并收到一条我以前从未见过的新错误消息:答案 0 :(得分:1)
在配置文件顶部的var recipes_number1 ;
$('.btn-random').click(function(){
recipes_number1 = Math.floor(Math.random() * 3);
var photo_url = Appetizer_photos[ recipes_number1 ];
var splitText = Appetizer[ recipes_number1 ];
$('#random-photo').attr('src',photo_url);
document.getElementById("list1").innerHTML= splitText;
;
});
var Appertizer_slide = Appertizer_name[recipes_number1];
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName(Appertizer_slide);
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
中定义了log4net
配置部分。
configSections