2011-03-23 124 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>添加了两个条目,或者它不是您的配置中的第一个子节点。

相关问题