Unrecognized configuration section appSettings

Problem description: A 64bit managed .Net service crashes with an exception "Configuration system failed to initialize" on a Win7 X64 OS.

I launched the App.exe in the debugger(https://msdn.microsoft.com/en-us/windows/hardware/gg463009) and took a crash dump https://support.microsoft.com/kb/286350 You may also run the following command: cscript adplus.vbs -crash –sc "<Path>App.exe"

After analyzing the crash dump, I found the below information:

0:000> |
.  0 id: 1f920 examine name: C:\Program Files\xxxxxxx\App.exe

0:000> kL100
Child-SP          RetAddr           Call Site
00000000`001aab20 000007fe`e6c3001f KERNELBASE!RaiseException+0x39
00000000`001aabf0 000007fe`e70d8ef5 mscorwks!RaiseTheExceptionInternalOnly+0x2ff
00000000`001aace0 000007fe`da68dedc mscorwks!JIT_Rethrow+0xe5
00000000`001aae80 000007fe`e6b75a21 System_Configuration_ni!System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)+0x33c
00000000`001aaee0 000007fe`e6b5ba9a mscorwks!ExceptionTracker::CallHandler+0x145
00000000`001aafe0 000007fe`e6bef7db mscorwks!ExceptionTracker::CallCatchHandler+0x9e
00000000`001ab070 00000000`77109dad mscorwks!ProcessCLRException+0x2ab
00000000`001ab110 00000000`770f8a4c ntdll!zzz_AsmCodeRange_End
00000000`001ab140 000007fe`e6c6d246 ntdll!RtlUnwindEx+0x539
00000000`001ab7e0 000007fe`e6bef787 mscorwks!ClrUnwindEx+0x36
00000000`001abcf0 00000000`77109d2d mscorwks!ProcessCLRException+0x257
00000000`001abd90 00000000`770f91cf ntdll!RtlpExecuteHandlerForException+0xd
00000000`001abdc0 00000000`77131248 ntdll!RtlDispatchException+0x45a
00000000`001ac4a0 000007fe`fd39940d ntdll!KiUserExceptionDispatch+0x2e
00000000`001aca60 000007fe`e6c3001f KERNELBASE!RaiseException+0x39
00000000`001acb30 000007fe`e7162380 mscorwks!RaiseTheExceptionInternalOnly+0x2ff
00000000`001acc20 000007fe`da68dded mscorwks!JIT_Throw+0x130
00000000`001acdd0 000007fe`e6b75a21 System_Configuration_ni!System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)+0x24d
00000000`001ace30 000007fe`e6b5ba9a mscorwks!ExceptionTracker::CallHandler+0x145
00000000`001acf30 000007fe`e6bef7db mscorwks!ExceptionTracker::CallCatchHandler+0x9e
00000000`001acfc0 00000000`77109dad mscorwks!ProcessCLRException+0x2ab
00000000`001ad060 00000000`770f8a4c ntdll!zzz_AsmCodeRange_End
00000000`001ad090 000007fe`e6c6d246 ntdll!RtlUnwindEx+0x539
00000000`001ad730 000007fe`e6bef787 mscorwks!ClrUnwindEx+0x36
00000000`001adc40 00000000`77109d2d mscorwks!ProcessCLRException+0x257
00000000`001adce0 00000000`770f91cf ntdll!RtlpExecuteHandlerForException+0xd
00000000`001add10 00000000`77131248 ntdll!RtlDispatchException+0x45a
00000000`001ae3f0 000007fe`fd39940d ntdll!KiUserExceptionDispatch+0x2e
00000000`001ae9b0 000007fe`e6c3001f KERNELBASE!RaiseException+0x39
00000000`001aea80 000007fe`e7162380 mscorwks!RaiseTheExceptionInternalOnly+0x2ff
00000000`001aeb70 000007fe`da76eb46 mscorwks!JIT_Throw+0x130
00000000`001aed20 000007fe`da690ae9 System_Configuration_ni!System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean)+0xce8e6
00000000`001aed60 000007fe`da68dd2c System_Configuration_ni!System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()+0x39
00000000`001aeda0 000007fe`da690698 System_Configuration_ni!System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)+0x18c
00000000`001aee20 000007fe`da6905f7 System_Configuration_ni!System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)+0x28
00000000`001aee50 000007fe`da6a3ba4 System_Configuration_ni!System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)+0x17
00000000`001aee90 000007fe`da697ee6 System_Configuration_ni!System.Configuration.ConfigurationManager.GetSection(System.String)+0x94
00000000`001aeed0 000007fe`dfdd4222 System_Configuration_ni!System.Configuration.ConfigurationManager.get_AppSettings()+0x26
00000000`001aef10 000007fe`d16772fc CoreManagementService_ni!DoubleTake.Internal.Service.ManagementService.ReadApplicationSettings()+0x22
00000000`001aef60 000007fe`dfdd5e72 DoubleTake_Common_ni!DoubleTake.Common.Service.ServiceBase.Start(System.String[])+0x1c
00000000`001aefa0 000007fe`e6d1d432 CoreManagementService_ni!DoubleTake.Internal.Service.Program.Main(System.String[])+0x32
00000000`001aefe0 000007fe`e6c0b7a3 mscorwks!CallDescrWorker+0x82
00000000`001af030 000007fe`e70fa981 mscorwks!CallDescrWorkerWithHandler+0xd3
00000000`001af0d0 000007fe`e6c686db mscorwks!MethodDesc::CallDescr+0x2b1
00000000`001af310 000007fe`e6c8bd54 mscorwks!ClassLoader::RunMain+0x22b
00000000`001af570 000007fe`e71e6c9d mscorwks!Assembly::ExecuteMainMethod+0xbc
00000000`001af860 000007fe`e6c9929f mscorwks!SystemDomain::ExecuteMainMethod+0x47d
00000000`001afe30 000007fe`e6c7bfdc mscorwks!ExecuteEXE+0x47
00000000`001afe80 000007fe`f91974e5 mscorwks!_CorExeMain+0xac
00000000`001afee0 000007fe`f9235b21 mscoreei!_CorExeMain+0xe0
00000000`001aff30 00000000`76ed652d mscoree!_CorExeMain_Exported+0x57
00000000`001aff60 00000000`7710c541 kernel32!BaseThreadInitThunk+0xd
00000000`001aff90 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

0:000> !pe
Exception object: 000000000245e1d8
Exception type: System.Configuration.ConfigurationErrorsException
Message: Configuration system failed to initialize
InnerException: System.Configuration.ConfigurationErrorsException
StackTrace (generated):
    SP               IP               Function
    00000000001ACDD0 000007FEDA68DEDD System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
    00000000001AEE20 000007FEDA690699 System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
    00000000001AEE50 000007FEDA6905F8 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
    00000000001AEE90 000007FEDA6A3BA5 System.Configuration.ConfigurationManager.GetSection(System.String)
    00000000001AEED0 000007FEDA697EE7 System.Configuration.ConfigurationManager.get_AppSettings()
    00000000001AEF10 000007FEDFDD4223 DoubleTake.Internal.Service.ManagementService.ReadApplicationSettings()
    00000000001AEF60 000007FED16772FD DoubleTake.Common.Service.ServiceBase.Start(System.String[])
    00000000001AEFA0 000007FEDFDD5E73 DoubleTake.Internal.Service.Program.Main(System.String[])

StackTraceString: <none>
HResult: 80131902
There are nested exceptions on this thread. Run with -nested for details

0:000> !do 000000000245e1d8
Name: System.Configuration.ConfigurationErrorsException
MethodTable: 000007feda6b3388
EEClass: 000007feda653e00
Size: 168(0xa8) bytes
GC Generation: 0
(C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll)
Fields:
              MT            Field           Offset                 Type VT             Attr            Value Name
000007fee5fb7d90  40000b5        8        System.String  0 instance                0 _className
000007fee5fb6138  40000b6       10 ...ection.MethodBase  0 instance                0 _exceptionMethod
000007fee5fb7d90  40000b7       18        System.String  0 instance                0 _exceptionMethodString
000007fee5fb7d90  40000b8       20        System.String  0 instance          245e168 _message
000007fee5faf3b0  40000b9       28 ...tions.IDictionary  0 instance                0 _data
000007fee5fb8058  40000ba       30     System.Exception  0 instance          245db98 _innerException
000007fee5fb7d90  40000bb       38        System.String  0 instance                0 _helpURL
000007fee5fb7680  40000bc       40        System.Object  0 instance          245e418 _stackTrace
000007fee5fb7d90  40000bd       48        System.String  0 instance                0 _stackTraceString
000007fee5fb7d90  40000be       50        System.String  0 instance                0 _remoteStackTraceString
000007fee5fbf000  40000bf       70         System.Int32  1 instance                0 _remoteStackIndex
000007fee5fb7680  40000c0       58        System.Object  0 instance                0 _dynamicMethods
000007fee5fbf000  40000c1       74         System.Int32  1 instance      -2146232062 _HResult
000007fee5fb7d90  40000c2       60        System.String  0 instance                0 _source
000007fee5fba798  40000c3       68        System.IntPtr  1 instance                0 _xptrs
000007fee5fbf000  40000c4       78         System.Int32  1 instance       -532459699 _xcode
000007fee5fb7d90  400315d       80        System.String  0 instance                0 _filename
000007fee5fbf000  400315e       7c         System.Int32  1 instance                0 _line
000007fee5fb7d90  4000254       88        System.String  0 instance                0 _firstFilename
000007fee5fbf000  4000255       98         System.Int32  1 instance                0 _firstLine
000007fee5fa5b80  4000256       90      System.Object[]  0 instance                0 _errors

0:000> !do 245db98
Name: System.Configuration.ConfigurationErrorsException
MethodTable: 000007feda6b3388
EEClass: 000007feda653e00
Size: 168(0xa8) bytes
GC Generation: 0
(C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll)
Fields:
              MT            Field           Offset                 Type VT             Attr            Value Name
000007fee5fb7d90  40000b5        8        System.String  0 instance                0 _className
000007fee5fb6138  40000b6       10 ...ection.MethodBase  0 instance                0 _exceptionMethod
000007fee5fb7d90  40000b7       18        System.String  0 instance                0 _exceptionMethodString
000007fee5fb7d90  40000b8       20        System.String  0 instance          245ab90 _message
000007fee5faf3b0  40000b9       28 ...tions.IDictionary  0 instance                0 _data
000007fee5fb8058  40000ba       30     System.Exception  0 instance                0 _innerException
000007fee5fb7d90  40000bb       38        System.String  0 instance                0 _helpURL
000007fee5fb7680  40000bc       40        System.Object  0 instance          245e038 _stackTrace
000007fee5fb7d90  40000bd       48        System.String  0 instance                0 _stackTraceString
000007fee5fb7d90  40000be       50        System.String  0 instance                0 _remoteStackTraceString
000007fee5fbf000  40000bf       70         System.Int32  1 instance                0 _remoteStackIndex
000007fee5fb7680  40000c0       58        System.Object  0 instance                0 _dynamicMethods
000007fee5fbf000  40000c1       74         System.Int32  1 instance      -2146232062 _HResult
000007fee5fb7d90  40000c2       60        System.String  0 instance                0 _source
000007fee5fba798  40000c3       68        System.IntPtr  1 instance                0 _xptrs
000007fee5fbf000  40000c4       78         System.Int32  1 instance       -532459699 _xcode
000007fee5fb7d90  400315d       80        System.String  0 instance                0 _filename
000007fee5fbf000  400315e       7c         System.Int32  1 instance                0 _line
000007fee5fb7d90  4000254       88        System.String  0 instance          244aa40 _firstFilename
000007fee5fbf000  4000255       98         System.Int32  1 instance                3 _firstLine
000007fee5fa5b80  4000256       90      System.Object[]  0 instance          245df38 _errors

0:000> !do 245ab90
Name: System.String
MethodTable: 000007fee5fb7d90
EEClass: 000007fee5bbe560
Size: 120(0x78) bytes
GC Generation: 0
(C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: Unrecognized configuration section appSettings.
Fields:
              MT            Field           Offset                 Type VT             Attr            Value Name
000007fee5fbf000  4000096        8         System.Int32  1 instance               48 m_arrayLength
000007fee5fbf000  4000097        c         System.Int32  1 instance               47 m_stringLength
000007fee5fb97d8  4000098       10          System.Char  1 instance               55 m_firstChar
000007fee5fb7d90  4000099       20        System.String  0   shared           static Empty
                                 >> Domain:Value  00000000003f2d10:00000000023a1308 <<
000007fee5fb9688  400009a       28        System.Char[]  0   shared           static WhitespaceChars
                                 >> Domain:Value  00000000003f2d10:00000000023a1b10 <<

It indicates that appSettings section in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config file has an invalid entry. Hence, the solution would be to compare the appSettings section in machine.config file on a working  system. It should be like this:

--><configuration>
<configSections>
  <section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false"/>

Sometime, you may also find that machine.config itself is missing on the system. In that scenario, copy the machine.config file from a working system(similar configuration) as the .NET Framework 2.0 is included as an OS component (Windows Vista, Windows Server 2008, Windows 7 and above OSs).