PDA

View Full Version : NHibernate with MS SQL Server 2005


abdulofpk
12-11-2006, 12:53 PM
Hi!
I have MS SQL Server 2005 installed on my system. I am using NHibernate to interact with my database named 'BRUSDB'. I have set the following configuration for nhibernate:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler , System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>

<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvi der"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2005Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="server=server; database=BRUSDB;user=sa;pwd=sorcim"
/>
</nhibernate>
</configuration>


when i run the program The type initializer for 'NHibernate.Cfg.Configuration' threw an exception:
'System.TypeInitializationException'
at line:
Configuration cfg = new Configuration();

If any one has know then kindly guid me.
Thanks.

Mark Pollack
12-13-2006, 08:42 PM
Hi,

Looks like one of the 'value' elements in the configuration is not a valid type. I notice there is an extra space DriverConnectionProvi_der in your listing but maybe that is cut-n-paste error from your file to the forum post. Looking into the exception detail/logging information may also provide clues. (which type is not found?)

Failing that, post a question on the NHibernate forum (http://forum.hibernate.org/viewforum.php?f=25), as this forum is intended for Spring/NHibernate integration.

Cheers,
Mark

abdulofpk
12-19-2006, 07:18 PM
Thanks for responding to my question.

There is no extra space in DriverConnectionProvider of app.config file.

praveen.chandran
11-22-2007, 10:01 AM
i think u forgot to add the assembly name in the code behind

like.

if (factory == null)
{
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("TMS");
factory = cfg.BuildSessionFactory();
}

:):):):)