2010-07-15 65 views
3

我想升级我的ASP.NET MVC 1网站到版本2.虽然这样做我不得不更新我所有的其他程序集。这也包括Castle的ActiveRecord dll。下面是我得到的错误:我的城堡ActiveRecord的问题是什么web.config

配置错误说明:需要 服务这个请求的配置文件的处理 过程中发生错误 。请查看 下面的具体错误详情, 正确修改您的配置文件 。

分析器错误信息:错误 发生创造了activerecord配置 节处理程序: 异常已被调用的 目标抛出。

<configSections> 
     <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" /> 
... 
</configSections> 

<activerecord isWeb="true" isDebug="false"> 
    <config> 
     <add 
     key="hibernate.connection.driver_class" 
     value="NHibernate.Driver.SqlClientDriver" /> 
     <add 
       key="hibernate.dialect" 
       value="NHibernate.Dialect.MsSql2005Dialect" /> 
     <add 
       key="hibernate.connection.provider" 
       value="NHibernate.Connection.DriverConnectionProvider" /> 
     <add 
           key="hibernate.connection.connection_string" 
           value="Data Source=(local)\SQLEXPRESS;Initial Catalog=db;Integrated Security=SSPI;" /> 
    </config> 
</activerecord> 

我这里看不到任何错误,我添加了 “冬眠”。在关键的由以下开头:

http://www.castleproject.org/activerecord/documentation/v1rc1/manual/xmlconfigref.html

它没有在那之前,所以我想可能是它为什么演戏了。

回答

2

NHibernate需要ProxyFactoryFactory的配置(就像消息说的那样)。最新发布的ActiveRecord附带城堡代理工厂的工厂,所以你可以将它设置这样的:

<add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"/> 

确保您有NHibernate.ByteCode.Castle.dll,Castle.DynamicProxy2.dll,城堡的参考。 Core.dll在您的应用程序中

您不需要设置release_mode属性,它是可选的。

在NHibernate 2.0中删除了用于配置属性的hibernate.前缀。您引用castleproject.org页面是为Castle ActiveRecord RC1(非常旧),它使用古老版本的NHibernate(1.0或类似的东西)。 ActiveRecord的XML配置参考的最新文档是here

+0

非常感谢帮助。 – rball 2010-07-15 22:17:59

+0

只是为了确保:它是真的'type =“NHibernate ...”'或者它只是'value =“NHibernate ...”'的拼写错误? – 2013-05-02 12:31:00

+0

@ anderson.pimentel谢谢,修正。还要注意这是针对NHibernate 2.x的 – 2013-05-02 13:27:55

2

您可能会缺少发布模式的密钥。

< add key =“hibernate.connection.release_mode”value =“on_close”/ >?

您是否有活动记录部分?

<节名称= “ActiveRecord的” TYPE = “Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler,Castle.ActiveRecord” requirePermission = “假”/ >

我只是猜测,尝试一下,让我们知道。

+0

由于某些原因,部分xml的东西没有显示在我的文章中。我更新了,以显示我有什么。感谢您的回应。我的机器上有 – rball 2010-07-15 05:35:57

+0

,这就是所需要的。你有所有的动态链接库和XML文件吗? – Zac 2010-07-15 07:28:50

0

这是我现在有:

<add 
      key="connection.driver_class" 
      value="NHibernate.Driver.SqlClientDriver" /> 
      <add 
        key="dialect" 
        value="NHibernate.Dialect.MsSql2000Dialect" /> 
      <add 
        key="connection.provider" 
        value="NHibernate.Connection.DriverConnectionProvider" /> 
      <add 
           key="connection.connection_string" 

我更新到最新城堡活动记录组件2.1.2和错误走了......现在我有:

The ProxyFactoryFactory was not configured. 
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. 
Example: 
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> 
Example: 
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> 

好亲切。 ..

相关问题