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

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

内容简介:翻译自: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


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

查看所有标签

猜你喜欢:

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

Head First Python(中文版)

Head First Python(中文版)

巴里(Barry.P.) / 林琪 等 / 中国电力出版社 / 2012-3-1 / 68.00元

你想过可以通过一本书就学会Python吗?《Head First Python(中文版)》超越枯燥的语法和甩法手册,通过一种独特的方法教你学习这种语言。你会迅速掌握Python的基础知识,然后转向持久存储、异常处理、Web开发、SQLite、数据加工和lGoogle App Engine。你还将学习如何为Android编写移动应用,这都要归功于Python为你赋予的强大能力。本书会提供充分并且完备......一起来看看 《Head First Python(中文版)》 这本书的介绍吧!

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

各进制数互转换器

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试