Could not find the dialect in the configuration

1,614 views
Skip to first unread message

Michiel

unread,
Jan 6, 2009, 10:25:58 AM1/6/09
to nhusers
I get the following error when using NHibernate 2.0.1.400:

NHibernate.MappingException : Could not compile the mapping document:
Foo.Model.Mappings.Region.hbm.xml
System.InvalidOperationException : Could not find the dialect in the
configuration
"Could not find the dialect in the configuration"

I have one mapping file in a separate assembly. Its build action is
set to Embedded Resource. Here's the file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Foo"
namespace="Foo.Model">
<class name="Region" table="Regions">
<id name="Id" column="Id" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
</class>
</hibernate-mapping>

My hibernate.cfg.xml is set to Copy always. Here's the file:

<?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.MsSql2005Dialect</
property>
<property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
<property name="connection.connection_string">Data
Source=localhost;Initial Catalog=Foo;Integrated Security=True</
property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>

Finally, this is the code to initialize the session factory:

Configuration configuration = new Configuration().AddAssembly("Foo");
sessionFactory = configuration.Configure().BuildSessionFactory();

What could be the problem?

Fabio Maulo

unread,
Jan 6, 2009, 10:37:32 AM1/6/09
to nhu...@googlegroups.com
which is the name of the NH configuration xml file ?

2009/1/6 Michiel <michi...@gmail.com>



--
Fabio Maulo

Christiaan Van den Poel

unread,
Jan 6, 2009, 10:32:23 AM1/6/09
to nhu...@googlegroups.com
I've had similar problems the last days.

Does your app.config contains a nhibernate section, this could also be the cause of this problem.

What I see also in your nhibernate.cfg.xml (and which causes also problems for me) is that you don't mention a ByteCode.provider (don't know yet what it does) like this:

    <property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>

HTH
C+++

Fabio Maulo

unread,
Jan 6, 2009, 10:40:36 AM1/6/09
to nhu...@googlegroups.com
2009/1/6 Christiaan Van den Poel <christiaan...@gmail.com>


What I see also in your nhibernate.cfg.xml (and which causes also problems for me) is that you don't mention a ByteCode.provider (don't know yet what it does) like this:

Christian, if you use the trunk is better if you stay up to date.

and some other blogs on the NET.

--
Fabio Maulo

Christiaan Van den Poel

unread,
Jan 6, 2009, 10:49:07 AM1/6/09
to nhu...@googlegroups.com
Fabio,

thx for the info
C+++

Michiel

unread,
Jan 6, 2009, 11:51:44 AM1/6/09
to nhusers
Well, I don't know about adding something that both of us don't even
know what it is for... also, I use the 2.0 release, nothing from the
trunk.

Thanks anyway!

On Jan 6, 4:32 pm, "Christiaan Van den Poel"
<christiaan.vandenp...@gmail.com> wrote:
> I've had similar problems the last days.
>
> Does your app.config contains a nhibernate section, this could also be the
> cause of this problem.
>
> What I see also in your nhibernate.cfg.xml (and which causes also problems
> for me) is that you don't mention a ByteCode.provider (don't know yet what
> it does) like this:
>
>     <property
> name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory,
> NHibernate.ByteCode.Castle</property>
>
> HTH
> C+++
>

Michiel

unread,
Jan 6, 2009, 11:53:26 AM1/6/09
to nhusers
hibernate.cfg.xml

I have it working now. I removed the AddAssembly("Foo") from the code,
and added a <mapping /> element to the configuration file. Now it
works, I don't know why the first way doesn't work though...

Thanks!

On Jan 6, 4:37 pm, "Fabio Maulo" <fabioma...@gmail.com> wrote:
> which is the name of the NH configuration xml file ?
>
> 2009/1/6 Michiel <michiel...@gmail.com>

Christiaan Van den Poel

unread,
Jan 6, 2009, 2:01:07 PM1/6/09
to nhu...@googlegroups.com
Michiel,

My mistake, I was playing with the trunk code, the last couple of days and had the same exceptions pupping, so I thought I could help a bit, only to realise I don't know much yet about NH.

Fabio Maulo

unread,
Jan 6, 2009, 2:58:35 PM1/6/09
to nhu...@googlegroups.com
2009/1/6 Michiel <michi...@gmail.com>

I have it working now. I removed the AddAssembly("Foo") from the code,
and added a <mapping /> element to the configuration file. Now it
works, I don't know why the first way doesn't work though...

The first way don't work because you are calling the AddAssembly method before call the Configure method.
--
Fabio Maulo

Michiel

unread,
Jan 6, 2009, 3:51:40 PM1/6/09
to nhusers
Oh ok, then I misunderstood what the Configure() method does.

Thanks for clearing this up!

-Michiel

On Jan 6, 8:58 pm, "Fabio Maulo" <fabioma...@gmail.com> wrote:
> 2009/1/6 Michiel <michiel...@gmail.com>
Reply all
Reply to author
Forward
0 new messages