Reputation: 61
When I try to initialize the nhibernate I'm getting this error.
System.TypeInitializationException was caught
Message=The type initializer for 'NHibernate.Cfg.Configuration' threw an exception.
Source=NHibernate
TypeName=NHibernate.Cfg.Configuration
StackTrace:
at NHibernate.Cfg.Configuration..ctor()
at FluentNHibernate.Cfg.FluentConfiguration..ctor() in D:\_development\fluent-nhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 27
at FluentNHibernate.Cfg.Fluently.Configure() in D:\_development\fluent-nhibernate\src\FluentNHibernate\Cfg\Fluently.cs:line 16
at Knoema.Application.Model.Repository.Initialize() in C:\Knoema\Knoema.Application.Model\Repository\Repository.cs:line 71
at ConsoleApplication1.Program.Main(String[] args) in C:\Knoema\ConsoleApplication1\Program.cs:line 19
InnerException: System.TypeInitializationException
Message=The type initializer for 'NHibernate.LoggerProvider' threw an exception.
Source=NHibernate
TypeName=NHibernate.LoggerProvider
StackTrace:
at NHibernate.LoggerProvider.LoggerFor(Type type)
at NHibernate.Cfg.Configuration..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
Message=Configuration system failed to initialize
Source=System.Configuration
BareMessage=Configuration system failed to initialize
Line=0
StackTrace:
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_AppSettings()
at NHibernate.LoggerProvider.GetNhibernateLoggerClass()
at NHibernate.LoggerProvider..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
Message=Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element. (C:\Knoema\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe.Config line 10)
Source=System.Configuration
BareMessage=Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.
Filename=C:\Knoema\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe.Config
Line=10
StackTrace:
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
Upvotes: 1
Views: 3870
Reputation: 3276
Only one <
configSections>
element allowed per config file and if present must be the first child of the root element. (C:\Knoema\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe.Config line 10)
Problem is mentioned in stack trace that you posted. Either you have put two entries for <configSections>
or it is not the first child in your config.
Upvotes: 3