简体   繁体   English

NHibernate 忽略 proxyfactory 属性

[英]NHibernate ignoring proxyfactory property

I upgraded from NH 2.1 / Fluent 1.1 to NH 3.1 / Fluent 1.2.我从 NH 2.1 / Fluent 1.1 升级到 NH 3.1 / Fluent 1.2。 I was using LinFu as proxy, however after the upgrade no matter what I configure NH tries to load Castle.我使用 LinFu 作为代理,但是升级后无论我配置什么 NH 都会尝试加载 Castle。 Im setting Fluent using我设置流利使用

 Configuration _Configuration;
 FluentConfiguration _FluentConfig;
 _Configuration = new Configuration();
 _Configuration.Configure();
 _FluentConfig = Fluently.Configure(_Configuration)
 .Mappings(m => m.FluentMappings.AddFromAssemblyOf<FluentNHSession>()))

Also nhibernate.cfg is configured to use linfu: nhibernate.cfg 也被配置为使用 linfu:

  <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> 

When running the application an exception is raised saying it cant find castle dll's.运行应用程序时会引发异常,说它找不到城堡 dll。 Using the same nhibernate.cfg but dropping castle ddl's in the bin directory works fine, seems like NH ignores the configuration.使用相同的 nhibernate.cfg 但在 bin 目录中删除城堡 ddl 工作正常,似乎 NH 忽略了配置。

I had the same problem.我有同样的问题。 I solved it by including this line in my fluent configuration.我通过在我的流利配置中包含这一行来解决它。

sessionFactory = Fluently.Configure(normalConfig)
              .Mappings(m =>
                  m.FluentMappings
                  .AddFromAssemblyOf<OrderHeaderMap>()
                  .Conventions.AddFromAssemblyOf<PascalCaseColumnNameConvention>())
               .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu")
              .BuildSessionFactory();

If this answer or any other answers here help you please mark it as the answer by clicking the check mark.如果此答案或此处的任何其他答案对您有帮助,请单击复选标记将其标记为答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM