2009-12-02 4 views
1

J'ai un ancien MonoRail/ActiveRecord J'ai aussi travaillé.Après la mise à niveau vers Castle Trunk et NHibernate 2.1.0.4000 Mon test d'intégration crash TestDriven.Net

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

Tout d'abord - Lorsque vous utilisez TestDriven.Net pour exécuter les tests d'intégration Cela fonctionne contre la base de données, il plante crash TestDriven.Net, ou tous les tests d'exécution complète, puis TestDriven.Net se bloque. Cela n'est jamais arrivé avant la mise à niveau.

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

seau défaut 1467169527, tapez 1 Nom de l'événement: APPCRASH Réponse: Non disponible Cab 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 cela a enregistré un deux fois, c'est à ce moment que TestDriven.Net se bloque.

est ici 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 les exceptions théoriques jetés dans Finaliser() doivent être avalés selon les docs MSDN:

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

Si Finaliser ou un remplacement de Finaliser lance une exception, l'exécution ignore l'exception, termine Finaliser la méthode et poursuit le processus de finalisation.

Pensées quelqu'un?

+0

Je ne suis pas sûr que DynamicProxy devrait remplacer la méthode 'Finalize' ... à la 1ère place –

Répondre

0

jamais tout à fait obtenu au fond de cette question, mais je ne finissent 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; 
    } 
} 
0

J'ai eu le même problème quand j'ai migré vers la version 2.1.2 de NHibernate. J'ai changé Castle pour LinFu Proxy et tout a bien fonctionné pour moi. J'espère que cela t'aides.

Questions connexes