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


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

查看所有标签

猜你喜欢:

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

Purely Functional Data Structures

Purely Functional Data Structures

Chris Okasaki / Cambridge University Press / 1999-6-13 / USD 49.99

Most books on data structures assume an imperative language such as C or C++. However, data structures for these languages do not always translate well to functional languages such as Standard ML, Ha......一起来看看 《Purely Functional Data Structures》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

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

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具