3

我尝试使用从主干构建的 NHibernate.Search 并与 NHibernate 2.0.1 一起使用。当我将一些 NHibernate.Search 属性配置添加到配置文件中时:

<property name="hibernate.search.default.directory_provider">NHibernate.Search.Storage.RAMDirectoryProvider, NHibernate.Search</property>
<property name="hibernate.search.default.indexBase">~\index\</property>

我得到一个无效的 System.Xml.Schema.XmlSchemaException:枚举约束失败。当我使用:

var configuration = new Configuration().Configure();

那么我该如何解决这个问题呢?

4

1 回答 1

3

确保您定义的 NHibernate.Search 属性包含在 nhs-configuration 块中,而不是标准 NHibernate 配置块中。您的 web.config 应如下所示:

<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="nhs-configuration" type="NHibernate.Search.Cfg.ConfigurationSectionHandler, NHibernate.Search" />

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <!-- nhibernate configuration block -->
</hibernate-configuration>

<nhs-configuration xmlns='urn:nhs-configuration-1.0'>
    <search-factory>
        <property name='hibernate.search.default.directory_provider'>NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search</property>

        <property name='hibernate.search.default.indexBase'>...</property>
    </search-factory>
</nhs-configuration>
于 2009-02-06T01:59:00.273 回答