Hibernate version:
NHibernate: 1.2.0.GA
Platform
Visual Studio .NET 2005 - .Net 2.0
Microsoft SQL Server 2000
Hi guys,
I've just downloaded NHibernate and I'm trying to get the "Quickstart with IIS and Microsoft SQL Server" working. And I'm having a few problems :S hoping someone can point me in the right direction.
I'm getting the error:
"The 'urn:nhibernate-mapping-2.2:hibernate-maping' element is not declared."
All the code is, with a few connection string changes straight from the sample.
And my solution is set up as a website, with the erroring line of code (see below) on the Page_Load of the default.aspx.cs. And my Class, Mapping and NHibernateHelper in a class library called QuickStart.
I'm hoping a have a bit of syntax wrong or I'm missing something or doing something silly.
This is what I have in my web.config:
Code:
<!-- Add this element -->
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Initial Catalog=quickstart;Data Source=.\SQLEXPRESS;User ID=sa;Password=computer;Persist Security Info=True</property>
<mapping assembly="QuickStart"/>
</session-factory>
</hibernate-configuration>
this is what I have in my mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-maping xmlns="urn:nhibernate-mapping-2.2" namespace="QuickStart" assembly="QuickStart">
<class name="Cat" table="Cat">
<!-- A 32 hex character is our surrogate key. It is automatically
generated by NHibernate with the UUID pattern. -->
<id name="Id">
<column name="CatId" sql-type="char(32)" not-null="true" />
<generator class="uuid.hex" />
</id>
<!-- A cat has to have a name, but it shouldn't be too long. -->
<property name="Name">
<column name="Name" length="16" not-null="true" />
</property>
<property name="Sex" />
<property name="Weight" />
</class>
</hibernate-maping>
This is the code in my Page_Load
Code:
ISession session = NHibernateHelper.GetCurrentSession();
And this is the constructor of the NHibernateHelper class where the exception is firing, on the
sessionFactory = new Configuration().Configure().BuildSessionFactory();Code:
using System;
using System.Web;
using NHibernate;
using NHibernate.Cfg;
namespace QuickStart
{
public sealed class NHibernateHelper
{
private const string CurrentSessionKey = "nhibernate.current_session";
private static readonly ISessionFactory sessionFactory;
static NHibernateHelper()
{
sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
public static ISession GetCurrentSession()
{
.
.
.
Hoping I'm not asking an annoying question.
Thanks in advance
Dave