Después de actualizar a Castillo Tronco y NHibernate 2.1.0.4000 Mi Pruebas de integración accidente TestDriven.Net

StackOverflow https://stackoverflow.com/questions/1832394

Pregunta

Tengo un viejo monorraíl / ActiveRecord que he estado haciendo algo de trabajo también.

Recientemente he decidido actualizar la aplicación a Castillo del tronco y NHibernate 2.1.0.4000 GA y ahora estoy encontrando algunos problemas con el funcionamiento de las pruebas:

En primer lugar - Al utilizar TestDriven.Net para ejecutar las pruebas de integración que trabajan contra la base de datos, que está chocando TestDriven.Net por completo, o todas las pruebas de ejecución completa, entonces TestDriven.Net cuelga. Esto nunca ocurrió antes de la actualización.

Cuando TestDriven.NET accidentes, esto es lo que se escribe en el registro de sucesos:

  

cubo Fault 1467169527, tipo 1   Nombre del evento: APPCRASH   Respuesta: No disponible   Cab Id: 0

     

Problema de la firma:   P1: ProcessInvocation86.exe   P2: 2.22.2468.0   P3: 4a26845c   P4: KERNELBASE.dll   P5: 6.1.7600.16385   P6: 4a5bdbdf   P7: e053534f   P8: 0000b727   P9:   P10:

segunda cosa - Las excepciones se registran cuando clases de proxy están siendo Finalizar () 'd, de la siguiente manera -. Que parece ser una vez que se registra un par de veces, que es cuando se bloquea TestDriven.Net

Aquí está el seguimiento de la pila de la excepción:

NHibernate.LazyInitializationException:     
Initializing[MyApp.Core.Models.TestExecutionPackage#15d9eb96-faf0-4b4b-9c5c-9cd400065430]-Could not initialize proxy - no Session.
  at NHibernate.Proxy.AbstractLazyInitializer.Initialize()
  at NHibernate.Proxy.AbstractLazyInitializer.GetImplementation()
  at NHibernate.ByteCode.Castle.LazyInitializer.Intercept(IInvocation invocation)
  at Castle.DynamicProxy.AbstractInvocation.Proceed()
  at Castle.Proxies.TestExecutionPackageProxy.Finalize()

El mismo comportamiento también se colgará MSBUILD en nuestro servidor CI.

Lo que es realmente extraño es que en la teoría de las excepciones lanzadas en Finalizar () deben tragarse según la documentación de MSDN:

http: // MSDN. microsoft.com/en-us/library/system.object.finalize(VS.71).aspx

Si Finalizar o una anulación de Finalizar lanza una excepción, el tiempo de ejecución ignora la excepción, termina que método Finalize, y continúa la finalización proceso.

Pensamientos alguien?

¿Fue útil?

Solución

nunca llegué a la parte inferior de este tema, pero lo hice llegar a la implementación de un trabajo bastante rudimentario torno al crear mi propia aplicación LazyInitializer, donde puedo comprobar si el método de invocación en Finalizar, como se muestra a continuación:

/// <summary>
/// Invoke the actual Property/Method using the Proxy or instantiate the actual
/// object and use it when the Proxy can't handle the method. 
/// </summary>
/// <param name="invocation">The <see cref="IInvocation"/> from the generated Castle.DynamicProxy.</param>
public virtual void Intercept(IInvocation invocation)
{
  try
  {
    if (invocation.Method.Name == "Finalize")
    {
      return;
    }
    if (_constructed)
    {
      // let the generic LazyInitializer figure out if this can be handled
      // with the proxy or if the real class needs to be initialized
      invocation.ReturnValue = base.Invoke(invocation.Method, invocation.Arguments, invocation.Proxy);

      // the base LazyInitializer could not handle it so we need to Invoke
      // the method/property against the real class
      if (invocation.ReturnValue == InvokeImplementation)
      {
        invocation.ReturnValue = invocation.Method.Invoke(GetImplementation(), invocation.Arguments);
        return;
      }
      else
      {
        return;
      }
    }
    else
    {
      // TODO: Find out equivalent to CGLIB's 'method.invokeSuper'.
      return;
    }
  }
  catch (TargetInvocationException tie)
  {
    // Propagate the inner exception so that the proxy throws the same exception as
    // the real object would 
    Exception_InternalPreserveStackTrace.Invoke(tie.InnerException, new Object[] { });
    throw tie.InnerException;
  }
}

Otros consejos

Yo tenía el mismo problema cuando un emigré a 2.1.2 versión de NHibernate. He cambiado Castillo en Linfu proxy y luego todo funcionó bien para mí. Esperamos que esto ayude.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top