Considerando este ejemplo como ejemplo base, creé la aplicación, pero cuando ejecuto esta aplicación recibo el siguiente error.ProxyFactoryFactory no se configuró
ProxyFactoryFactory no estaba configurado. Inicialice la propiedad 'proxyfactory.factory_class' de la sección de configuración de la fábrica de sesiones con uno de los proveedores de NHibernate.ByteCode disponibles. Ejemplo: NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu Ejemplo: NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
El siguiente es el fragmento de código que estoy utilizando.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NHibernate;
using NHibernate.Cfg;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "[email protected]";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
session.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
}
Y mi archivo app.config
parece
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI"
/>
<!--<add value="nhibernate.bytecode.castle.proxyfactoryfactory, nhibernate.bytecode.castle" key="proxyfactory.factory_class" />-->
<!--<property name="proxyfactory.factory_class">NHibernate.ByteCode.Linfu.ProxyFactoryFactory, NHibernate.ByteCode.Linfu</property>-->
<!-- I have tried both the lines but still getting the same error -->
</nhibernate>
</configuration>
tengo LinFu.DynamicProxy.dll
en lugar de linfu.dll
. ¿Funcionará? Si no, ¿de dónde saco esto linfu.dll
? ¿O hay alguna otra solución?
duplicados probables: http://stackoverflow.com/questions/956281/nhibernate-proxyexception y http://stackoverflow.com/questions/969894/error-using-nhibernate –
También hay un error con el build target http://blog.frozzn.com/2010/03/nhibernatebytecodecastleproxyfactoryfac.html – cgreeno