I have a program that worked on this Monday (2018-10-01) but started to crash on Wednesday (it wasn't used on Tuesday).
The program is at a customer and in release form, so I can't debug it! The customer says that "Nothing has changed" and all the files in my program is as before.
It's a C# Winforms program and I have, via Event Viewer, found out that the crash happens when NLog is starting (in ctor).
I have tried to use internal logging but no log file is created.
Any ideas on what the problem is and/or how I should fix it?
The message in Event Viewer Application:
DCMark Winform.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Xml.XmlException at System.Xml.XmlTextReaderImpl.Throw(System.Exception) at System.Xml.XmlTextReaderImpl.Throw(System.String, System.String[])
at System.Xml.XmlTextReaderImpl.ParseText(Int32 ByRef, Int32 ByRef, Int32 ByRef) at System.Xml.XmlTextReaderImpl.ParseText() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Xml.XmlTextReaderImpl.Skip() at System.Xml.XmlTextReader.Skip() at System.Configuration.XmlUtil.StrictSkipToNextElement(System.Configuration.ExceptionAction) at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(System.Configuration.XmlUtil, System.String, Boolean, System.String, System.Configuration.OverrideModeSetting, Boolean) at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(System.Configuration.XmlUtil, System.String, Boolean, System.String, System.Configuration.OverrideModeSetting, Boolean) at System.Configuration.BaseConfigurationRecord.ScanSections(System.Configuration.XmlUtil) at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean) at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(System.Configuration.ConfigurationSchemaErrors) at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs)Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(System.String) at System.Configuration.ConfigurationManager.get_AppSettings() at NLog.Common.InternalLogger.GetSettingString(System.String, System.String) at NLog.Common.InternalLogger.GetSetting[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.String, Boolean) at NLog.Common.InternalLogger..cctor()Exception Info: System.TypeInitializationException at DC.DCMark.Form1..ctor() at DC.DCMark.Program.Main()
The NLog.config file
<?xml version="1.0" encoding="utf-8" ?>
<nlog throwExceptions="true"
internalLogFile="C:/Temp/log.txt" internalLogLevel="Trace">
<targets>
<target xsi:type="File" name="f" fileName="${specialfolder:folder=CommonApplicationData}/Foo/Bar/Logs/Bar_${shortdate}.log"
layout="${longdate} | ${uppercase:${level}} | ${callsite} | ${message} | ${exception:format=ToString}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="f" />
</rules>
</nlog>
EDIT: Added the App.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DC.DCMark.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<userSettings>
<DC.DCMark.Properties.Settings>
<setting name="Location" serializeAs="String">
<value>400, 100</value>
</setting>
<setting name="Size" serializeAs="String">
<value>840, 900</value>
</setting>
<setting name="Maximised" serializeAs="String">
<value>False</value>
</setting>
<setting name="Minimised" serializeAs="String">
<value>False</value>
</setting>
</DC.DCMark.Properties.Settings>
</userSettings>
</configuration>
throwExceptions="true"
should never be used in a production environment. It is only intended for unit-testing or similar. It has many unwanted side-effects. – Rolf Kristensen