What is the problem with my Castle ActiveRecord web.config
I'm trying to upgrade my ASP.NET MVC 1 website to version 2. While doing this I'm having to update all of my other assemblies as well. This includes Castle's ActiveRecord dll as well. Here is the error I'm getting:
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred creating the configuration section handler for activerecord: Exception has been thrown by the target of an invocation.
<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
开发者_如何学Python key="hibernate.connection.connection_string"
value="Data Source=(local)\SQLEXPRESS;Initial Catalog=db;Integrated Security=SSPI;" />
</config>
</activerecord>
I don't see anything wrong here, I added "hibernate." to the beginning of the key's by following:
http://www.castleproject.org/activerecord/documentation/v1rc1/manual/xmlconfigref.html
It didn't have that before so I thought that may have been why it was acting up.
NHibernate needs the configuration for the ProxyFactoryFactory (just like the message says). The latest ActiveRecord release ships with the Castle proxy factory factory so you can set it up like this:
<add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"/>
Make sure you have a reference to NHibernate.ByteCode.Castle.dll, Castle.DynamicProxy2.dll, Castle.Core.dll in your application
You don't need to set the release_mode
property, it's optional.
The hibernate.
prefix for config properties was dropped in NHibernate 2.0. The castleproject.org page you quote is for Castle ActiveRecord RC1 (very old), which used an ancient version of NHibernate (1.0 or something like that). The latest docs for XML config reference for ActiveRecord is here.
You might be missing a key for release mode.
<add key="hibernate.connection.release_mode" value="on_close"/>?
Do you have an Active Record section?
<section name="activeRecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" requirePermission="false"/>
I'm only guessing, try it out and let us know.
Here's what I have now:
<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"
I updated to latest Castle Active Record assemblies 2.1.2 and that error went away...now I have:
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>
good gracious ...
精彩评论