.net × 70788 Инициализатор типа для «NHibernate.Cfg.Configuration» выдал исключение - PullRequest
1 голос
/ 23 марта 2011

Когда я пытаюсь инициализировать nhibernate, я получаю эту ошибку.

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)

1 Ответ

2 голосов
/ 23 марта 2011

Для каждого файла конфигурации разрешен только один элемент <<code>configSections>, и если он присутствует, он должен быть первым дочерним элементом корневого элемента.(C: \ Knoema \ ConsoleApplication1 \ bin \ Debug \ ConsoleApplication1.vshost.exe.Config строка 10)

Проблема упоминается в трассировке стека, которую вы опубликовали.Либо вы добавили две записи для <<code>configSections>, либо это не первый дочерний элемент в вашей конфигурации.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...