私は開発者として作業を始めましたが、同じ問題を何度も何度も繰り返しています。NHibernateの設定エラー
Exception (SessionFactory): An exception occurred during configuration of persistence layer./ em NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration..ctor(XmlReader hbConfigurationReader, Boolean fromAppSetting) em NHibernate.Cfg.Configuration.Configure(XmlReader textReader) em NHibernate.Cfg.Configuration.Configure(String fileName, Boolean ignoreSessionFactoryConfig) em DataLayer.Repository.NHibernateHelper.get_SessionFactory() at 14/12/2016 16:52:52 0 PCService Error on: 14/12/2016 16:52:52 Referência de objeto não definida para uma instância de um objeto. em DataLayer.Repository.ConfigRobotRepository.FindByName(String name) em RSPC.PCService.ScheduleService() at line 0
私はhibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.MySQLDialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.MySqlDataDriver
</property>
<property name="connection.connection_string">
Server=localhost; Database=bd; Uid=ti; Pwd=************;
</property>
<property name="show_sql">false</property>
</session-factory>
</hibernate-configuration>
マイNHibernateHelper.cs:すべてのヘルプははるかに高く評価されて
public class NHibernateHelper
{
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
try
{
if (_sessionFactory == null)
//CreateSessionFactory();
{
var configuration = new Configuration();
//configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, ConnectionString);
configuration.Configure("hibernate.cfg.xml");
configuration.AddAssembly(typeof(ConfigRobot).Assembly);
_sessionFactory = configuration.BuildSessionFactory();
}
return _sessionFactory;
}
catch (Exception e)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true);
var frame = trace.GetFrame(0);
var line = frame.GetFileLineNumber();
Log("Exception (SessionFactory): " + e.Message + "/" + e.StackTrace + " at {0} " + line, Path.GetTempPath() + "PCService" + ".txt");
return null;
}
}
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
私はこのエラーを得続けます!ありがとう!
デバッグ中ですか? NHibernateの設定を 'Copy Always'にセットしておくことで、ビルド/実行時にDebugとReleaseフォルダに終わるようにしてください。 – TyCobb
あなたのパスワードを投稿しましたか? :) –
@KeithNicholasはちょうど編集しましたが、私はあまりにも多くの時間を過ごした後にそれに気付かなかった –