views:

15

answers:

1

I have an NHibernate configuration file as follows:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory name="MyProject">
    <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_name">MyProject</property>
    <property name="connection.isolation">ReadCommitted</property>
    <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
    <property name="cache.use_second_level_cache">true</property>
    <property name="cache.use_query_cache">true</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
  </session-factory>
</hibernate-configuration>

When creating the Configuration object:

Configuration cfg = new Configuration();
cfg.AddFile(nhibernateConfigurationFile);

I'm getting the following errors when trying to run a persistence test:

  • System.InvalidOperationException: Could not find the dialect in the configuration

  • NHibernate.MappingException: Could not compile the mapping document: C:\PathToProject\bin\Debug\NHibernateMyProject.config

Anyone know why it is having trouble reading the nhibernate config file? From what I am able to see, the dialect is definitely in the config....

A: 

Hi,

You should use this dialect: NHibernate.Dialect.MsSql2000Dialect

Try to define the assembly which contains the mapping files:

<mapping assembly="yourAssembly"/>

For the configuration file:

new Configuration().Configure( yourfile.cfg.xml );
mynkow