Spring.Net + NHibernate-未声明'http://www.springframework.net/database:provider'元素 [英] Spring.Net + NHibernate - The 'http://www.springframework.net/database:provider' element is not declared

查看:83
本文介绍了Spring.Net + NHibernate-未声明'http://www.springframework.net/database:provider'元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些Spring和NHibernate问题,似乎没人能解决.我以NorthWind项目为例.现在,我收到此错误:

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.'

这是指我XML中的以下位:

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"/>

我包含了正确的名称空间,将xsd添加到了我的项目中,并将解析器添加到了我的App.config文件中:

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" />

<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.

推荐答案

它根本没有加载我的App.config文件,因此它从未加载解析器.

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

我添加了以下代码:

NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));

它奏效了.

这篇关于Spring.Net + NHibernate-未声明'http://www.springframework.net/database:provider'元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆