Я работаю в проекте Xamarin и пытаюсь использовать NHibernate. Я создал проект библиотеки, который содержит мои модели, отображения, методы (получить, сохранить) и фабрику сеансов.
У меня также есть проект Test в моем решении, который ссылается на проект библиотеки, о котором я упоминал ранее, и он отлично работает. Я могу читать и писать в базе данных без проблем.
Однако, когда я ссылаюсь на проект библиотеки в проекте Xamarin .Net Standard 2.0 и пытаюсь открыть сеанс, я получаю исключение System.TypeInitializationException.
Это трассировка стека:
The type initializer for 'RangoJaDatabaseAccess.NHibernate.NHibernateHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NHibernate.NHibernateLogger' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0
at NHibernate.NHibernateLogger.GetNhibernateLoggerClass () [0x00000] in <aba00f10777942a58e2f657e5e04cdfc>:0
at NHibernate.NHibernateLogger..cctor () [0x00000] in <aba00f10777942a58e2f657e5e04cdfc>:0
--- End of inner exception stack trace ---
at NHibernate.Cfg.Configuration..cctor () [0x00000] in <aba00f10777942a58e2f657e5e04cdfc>:0
--- End of inner exception stack trace ---
at RangoJaDatabaseAccess.NHibernate.NHibernateHelper..cctor () [0x00025] in C:\WorkingCopy\_rango_ja\rangoja\RangoJa\RangoJaDatabaseAccess\NHibernate\NHibernateHelper.cs:22
--- End of inner exception stack trace ---
at RangoJaDatabaseAccess.NHibernate.DatabaseOperations.GetAllObjects[T] () [0x00001] in C:\WorkingCopy\_rango_ja\rangoja\RangoJa\RangoJaDatabaseAccess\NHibernate\DatabaseOperations.cs:65
at RangoJa.ViewModel.SearchRecipePageViewModel.LoadAllIngredients () [0x00002] in C:\WorkingCopy\_rango_ja\rangoja\RangoJa\RangoJa\RangoJa\ViewModel\SearchRecipePageViewModel.cs:31 } System.TypeInitializationException
Это мой код конфигурации NHibernate:
sessionFactory = new Configuration().Configure()
.AddAssembly("RangoJaDatabaseAccess").BuildSessionFactory();
Это мой XML-файл конфигурации NHibernate:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<!-- Aqui você deve coloca o seu Connection String -->
<property name="connection.connection_string">
Server=remotemysql.com;Database=cInQeeudyg;User ID=cInQeeudyg;Password=xxxxx;
</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="current_session_context_class">async_local</property>
</session-factory>
</hibernate-configuration>
Любая помощь будет оценена, спасибо.