Après la mise à niveau du château Tronc et NHibernate 2.1.0.4000 Mes tests d'intégration accident TestDriven.Net

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

Question

J'ai un vieux monorail / ActiveRecord Je fais un travail aussi.

Récemment j'ai décidé de mettre à jour l'application du château et du coffre NHibernate 2.1.0.4000 GA et je trouve maintenant quelques problèmes avec l'exécution des tests:

Tout d'abord - Lorsque vous utilisez TestDriven.Net pour exécuter les tests d'intégration qui travaillent contre la base de données, il est tout à fait écraser TestDriven.Net, ou tous les tests d'exécution complète, puis TestDriven.Net se bloque. Cela n'a jamais eu lieu avant la mise à niveau.

Quand TestDriven.NET accidents, voici ce qui les écrit dans le journal des événements:

  

Godet de défaut 1467169527 type 1   Nom de l'événement: APPCRASH   Réponse: Non disponible   Cabine Id: 0

     

Signature du problème:   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:

La deuxième chose - Les exceptions sont enregistrées lorsque les classes proxy sont en cours Finaliser () 'd, comme ci-dessous -. Il semble être une fois que c'est enregistré plusieurs fois, c'est quand TestDriven.Net accidents

Voici la trace de la pile de l'exception:

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()

Le même comportement se bloque également MsBuild sur notre serveur CI.

Ce qui est vraiment étrange est que dans la théorie des exceptions lancées dans Finaliser () doivent être avalés selon les docs MSDN:

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

Si Finalize ou une substitution de Finalize renvoie une exception, le moteur d'exécution ignore l'exception, se termine que Finalize méthode , et continue la mise au point processus.

Pensées quelqu'un?

Était-ce utile?

La solution

Jamais tout à fait arrivé au fond de cette question, mais j'ai fini par mettre en œuvre un travail assez rudimentaire autour en créant ma propre implémentation LazyInitializer, où je vérifie la méthode Finaliser sur Invoke, comme indiqué ci-dessous:

/// <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;
  }
}

Autres conseils

J'ai eu le même problème lorsque je migré vers 2.1.2 version de NHibernate. J'ai changé pour le château Linfu Proxy et puis tout a bien fonctionné pour moi. Espérons que cela aide.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top