Enterprise Library 5.0 Logging exception on startup

189 Views Asked by At

The application is running on multiple clients. Today I had an incident, where after a power failure, the application was not starting again.

Following are the exceptions from the event log

Faulting application name: MyApplication.exe, version: 7.3.0.14, time stamp: 0x626786ff
Faulting module name: KERNELBASE.dll, version: 6.1.7601.24561, time stamp: 0x5f76968d
Exception code: 0xe0434352
Fault offset: 0x0000c5af
Faulting process id: 0xeb4
Faulting application start time: 0x01d8d17277e726c1
Faulting application path: C:\Program Files (x86)\MyCompany\Visu\MyApplication.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: b5b2baf1-3d65-11ed-b8b3-00139548ead0

Detailed exception

Application: MyApplication.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.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlTextReader.Read()
   at System.Configuration.XmlUtil..ctor(System.IO.Stream, System.String, Boolean, System.Configuration.ConfigurationSchemaErrors)
   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.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs)
   at System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(System.Configuration.Internal.InternalConfigEventArgs)
   at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(System.String, System.Configuration.BaseConfigurationRecord)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(System.String, Boolean, Boolean, Boolean, Boolean, System.Object ByRef, System.Object ByRef)
   at System.Configuration.BaseConfigurationRecord.GetSection(System.String)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
   at System.Configuration.ConfigurationManager.GetSection(System.String)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.GetConfigurationSourceSection()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceFactory.Create()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current()
   at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
   at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(System.Object, System.String, Int32, Int32)
   at MyApplication.App.Main(System.String[])

Code:

[System.STAThreadAttribute()]
public static void Main(string[] args)
{
  Logger.Write("Application was started on:" + DateTime.Now, "Core", 100, 100);
  ...
}  

As I had no possiblity for remote debugger, I copied the complete application folder from the client to my dev machine. Everything was working properly. The application started and the UI was displayed.

On the client machine I tried the following

  • checked the application.config file - everything OK
  • starting the application with administrative rights - same exception
  • moving the folder from the "program files" directory to somewhere different, including all configuration files - same exception
  • comparing the current application folder with initial folder after the setup, all files are equal - same exception

As a last point, i updated the code of the main method with a try catch block around the call to the Enterprise Logger. I compiled the exe and started the updated version on the client computer. Only the exe and manifest file have been updated! The application started and the catch block was never triggered.

I switched back to the "previously corrupted?" version and now it was successfully running.

From the text i assume that something must be wrong the the app.config file. But then it would also throw the exception on my dev machine and would still throw the exception after the update of the app.exe.

What could be the reason of the above exception?

1

There are 1 best solutions below

0
AFrueh On

With the tips from @PanagiotisKanavos the solution of the problem was possible.

Checking the file access with procmon, i realised that there was a user.config file stored at C:<Users><Username>\AppData\Local<MyCompany><MyApp><AppVersion>. This file was corrupt - filled with '\0' - due to the power failure. At startup the user.config file was merged with the app.config file and this crashed the application.