C# Programming
05-07-2009, 07:00 PM
Hi all,
I'm doing a program that saves customer details to the database and I'm using NHibernate. I'm very new in it and I'm getting help from the net. I have a problem compiling the mapping file, I get the following error:
"Could not compile the mapping document: Customer.hbm.xml"
I don't have an idea of what I did wrong. Please, if you know what I missed or did wrong, I'd really appreciate your help/advice. Thanks.
Here is my class:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate_Demo
{
class Program
{
static void Main(string[] args)
{
// Loads the NHibernate Types to prepare for Serialization
Configuration cfg = new Configuration();
cfg.Configure();
//cfg.AddAssembly(typeof(NHibernate_Demo.Customer).Assembly);
//cfg.AddClass(typeof(Customer));
cfg.AddFile("Customer.hbm.xml");
//Opens a session to NHiberbate to allow us to work with objects
ISessionFactory sessionsF = cfg.BuildSessionFactory();
//let ISessiionFactory open connection
ISession sessionS = sessionsF.OpenSession();
ITransaction transaction = sessionS.BeginTransaction();
{
Customer customer = (Customer)
sessionS.Load(typeof(Customer), "ALFKI");
// Show the Contact Name of the Customer
//MessageBox.Show(customer.ContactName);
sessionS.Close();
}
}
}
}
I get an error at this line:
cfg.AddFile("Customer.hbm.xml");
Thanks.
I'm doing a program that saves customer details to the database and I'm using NHibernate. I'm very new in it and I'm getting help from the net. I have a problem compiling the mapping file, I get the following error:
"Could not compile the mapping document: Customer.hbm.xml"
I don't have an idea of what I did wrong. Please, if you know what I missed or did wrong, I'd really appreciate your help/advice. Thanks.
Here is my class:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate_Demo
{
class Program
{
static void Main(string[] args)
{
// Loads the NHibernate Types to prepare for Serialization
Configuration cfg = new Configuration();
cfg.Configure();
//cfg.AddAssembly(typeof(NHibernate_Demo.Customer).Assembly);
//cfg.AddClass(typeof(Customer));
cfg.AddFile("Customer.hbm.xml");
//Opens a session to NHiberbate to allow us to work with objects
ISessionFactory sessionsF = cfg.BuildSessionFactory();
//let ISessiionFactory open connection
ISession sessionS = sessionsF.OpenSession();
ITransaction transaction = sessionS.BeginTransaction();
{
Customer customer = (Customer)
sessionS.Load(typeof(Customer), "ALFKI");
// Show the Contact Name of the Customer
//MessageBox.Show(customer.ContactName);
sessionS.Close();
}
}
}
}
I get an error at this line:
cfg.AddFile("Customer.hbm.xml");
Thanks.