views:

273

answers:

1

I’m having some Spring and NHibernate issues which nobody seems to be able to resolve. I'm using the NorthWind project as an example to go off of. Right now I’m getting this error:

'MyNamespace.MyClass.MyFunction:
Spring.Objects.Factory.ObjectDefinitionStoreException : Line 6 in XML document from assembly [MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=334479e19ddfb52d], resource [MyNamespace.Dao.xml] violates the schema.  The 'http://www.springframework.net/database:provider' element is not declared.
  ----> System.Xml.Schema.XmlSchemaValidationException : The 'http://www.springframework.net/database:provider' element is not declared.'

The refers to the following bit in my XML:

<db:provider id="DbProvider"
           provider="System.Data.SqlClient"
           connectionString="Data Source=MyServer\MyDatabase;Initial Catalog=master;Integrated Security=True"/>

I’ve included the correct namespace, added the xsd’s to my project, and added the parser to my App.config file:

  <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />

and

<spring>
  <parsers>
    <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
  </parsers>
</spring>

But it doesn’t seem to be picking it up. Any ideas why I’m getting this error? Everywhere I read says the error is because I haven’t defined the parser, but I obviously have.

A: 

It isn't loading my App.config file at all, so it was never loading the parser.

I added the following code:

NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));

and it worked.

McAden