I've read the manual, I've had working code, I've searched the forums for a solution. Still nothing.
Now I was sure this new project was put together in much the same way as the old one, but I'm getting the "Could not find the dialect in the configuration" exception.
My App.conf configuration file is as follows:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">
NHibernate.Dialect.MsSql2005Dialect
</property>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Data Source=developmentserver;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=secret;
</property>
</session-factory>
</hibernate-configuration>
<connectionStrings>
<add name="HUGOS"
connectionString="Data Source=developmentserver;Initial Catalog=mydb1;Persist Security Info=True;User ID=username;Password=secret."
providerName="System.Data.SqlClient" />
<add name="Security"
connectionString="Data Source=developmentserver;Initial Catalog=mydb2;Persist Security Info=True;User ID=username;Password=secret."
providerName="System.Data.SqlClient" />
<add name="Directory"
connectionString="Data Source=developmentserver;Initial Catalog=mydb3;Persist Security Info=True;User ID=username;Password=secret."
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I have two libraries. One with my entities, and one with my data access code. My data access code is along the following lines:
Code:
private ISession CreateSession<TObject>(TObject entity)
{
if (this._session == null)
{
this._configuration = new NHibernate.Cfg.Configuration();
this._configuration.Configure();
this._configuration.AddAssembly(typeof(TObject).Assembly);
this._configuration.SetProperty("hibernate.connection.connection_string_name", this._connectionName);
this._factory = this._configuration.BuildSessionFactory();
this._session = this._factory.OpenSession();
this._session.FlushMode = FlushMode.Commit;
}
else
{
if (this._session.IsOpen == true) { }
else
{
this._session = this._factory.OpenSession();
}
}
return this._session;
}
The App.conf is in my unit test library, which references both the entities and the data access libraries. This is driving me crazy. All help is appreciated.
Hibernate version: 2.0.0 Mapping documents:Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="AJBG.Directory.Entities.Logs.Security_Log, AJBG.Directory.Entities" table="Security_Log" lazy="true">
<id name="LogId" type="Int32">
<generator class="native" />
</id>
<many-to-one name="LogType" column="LogType" not-null="true" fetch="join" cascade="none" />
<property name="AccountName" type="String" length="20" not-null="false" insert="true" update="true" unique="false" />
<property name="Message" type="String" not-null="true" />
</class>
</hibernate-mapping>
Name and version of the database you are using:
Microsoft SQL Server 2005