2011-03-23 72 views
1

當我嘗試初始化nhibernate時,出現此錯誤。.net×70788'NHibernate.Cfg.Configuration'的類型初始值設定項引發異常

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) 

回答

2

只有一個< configSections>元件 每配置文件並且如果存在 允許必須是根 元件的第一個子。 (C:\ Knoema \ ConsoleApplication1 \ BIN \調試\ ConsoleApplication1.vshost.exe.Config 第10行)

問題是在你張貼堆棧跟蹤提及。或者您已經爲< configSections>添加了兩個條目,或者它不是您的配置中的第一個子節點。

相關問題