c# – Fluent NHibernate – 在配置持久层期间发生异常

栏目: ASP.NET · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/1630886/fluent-nhibernate-exception-occurred-during-configuration-of-persistence-layer

我正在使用Fluent NHibernate和一个外部’hibernate.cfg.xml’文件.

以下是我收到错误的配置代码:

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

       _sessionFactory = Fluently.Configure(configuration)
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Template>())
                .BuildSessionFactory();

        return _sessionFactory;

但是当NHibernate试图配置时,我得到了错误:

在配置持久层期间发生异常.

内部例外说:

The ProxyFactoryFactory was not configured.  Initialize ‘proxyfactory.factory_class’ property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.

我用谷歌搜索,根据我发现的一些解决方案,我做了以下更改:

>将以下dll添加到我的app bin:

Castle.Core.dll,Castle.DynamicProxy2.dll,NHibernate.ByteCode.Castle.dll

>在hibernate.cfg.xml中添加了follewing属性

<property name =“proxyfactory.factory_class”> NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</ property>

但我仍然得到同样的例外.

问题可能在你的hibernate.cfg.xml中,使用2.2版本的双重检查,如果形成良好.

映射应该像这样开始:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

除了您发布的错误,可能会提供更多信息,因为该错误对配置解析器非常通用.如果没有,也许您可​​以提供有关hibernate.cfg.xml的更多详细信息.

翻译自:https://stackoverflow.com/questions/1630886/fluent-nhibernate-exception-occurred-during-configuration-of-persistence-layer


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Ethnography and Virtual Worlds

Ethnography and Virtual Worlds

Tom Boellstorff、Bonnie Nardi、Celia Pearce、T. L. Taylor / Princeton University Press / 2012-9-16 / GBP 21.00

"Ethnography and Virtual Worlds" is the only book of its kind - a concise, comprehensive, and practical guide for students, teachers, designers, and scholars interested in using ethnographic methods t......一起来看看 《Ethnography and Virtual Worlds》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换