tags:

views:

378

answers:

1

Hi, I'm doing a project in Nhibernate with MySql in asp.net. In that while executing the code I got the error like "An exception occurred during configuration of persistence layer" in the below line

ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure).BuildSessionFactory();

So let me help to trouble shoot the error.

Here s my Configuration file

NHibernate.Connection.DriverConnectionProvider NHibernate.Driver.MySqlDataDriver Server=localhost;Database=hrms;User ID=test;Password=test; NHibernate.Dialect.MySQL5Dialect true

A: 

Incomplete configuration perhaps? Try manual configuration initialization like the following:

NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.SetProperty("dialect", "NHibernate.Dialect.MySQLDialect");
cfg.SetProperty("connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
cfg.SetProperty("connection.connection_string", "Server=YourServer;Database=YourDatabase;User ID=YourId;Password=YourPass;CharSet=utf8");
cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu");  
cfg.AddAssembly("Your.Assembly.Name");  
ISessionFactory sessionFactory = cfg.BuildSessionFactory();

If everything works, move it to XML if you like.

Jaya Wijaya
Hi Jaya, sorry for this. Actually i'm new to this NHibernate. So let me tell u, hw can I cofigure mannualy using ur code.?
S.Siva
While using ur code, I got tat mapping exception was unhandled by user code error
S.Siva
Can you show me the mapping file and where did you put the mapping file? also in the code above, it is assumed that the mapping file is in the Your.Assembly.Name assembly.
Jaya Wijaya
I added my assemply file in tat place, but I got "Could not add assembly WebApp1.Job.hbm.xml" error..
S.Siva
you need to give the detailed error. or even better if you could show me the mapping file.
Jaya Wijaya