Nach dem Upgrade auf Schloss Trunk und NHibernate 2.1.0.4000 Meine Integrationstests Crash TestDriven.Net

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

Frage

Ich habe eine alte Monorail / Active Ich habe auch einige Arbeit getan.

Vor kurzem habe ich beschlossen, um die Anwendung zu Castle Trunk & NHibernate 2.1.0.4000 GA zu aktualisieren, und ich bin jetzt ein paar Probleme mit dem Ausführen von Tests zu finden:

Als erstes - Wenn TestDriven.Net mit den Integrationstests auszuführen, die für die Datenbank arbeiten, es stürzt TestDriven.Net ganz oder alle Tests vollständig ausgeführt, dann TestDriven.Net hängt. Diese nie vor dem Upgrade passiert ist.

Wenn TestDriven.NET abstürzt, ist hier, was in das Ereignisprotokoll geschrieben wird:

  

Fehler Eimer 1467169527, Typ 1   Ereignisname: APPCRASH   Antwort: Nicht verfügbar   Cab Id: 0

     

Problemsignatur:   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:

Die zweite Sache - Ausnahmen protokolliert werden, wenn Proxy-Klassen Finalisierung werden () 'd, wie unten -. Scheint es einmal zu sein, dies ein paar Mal angemeldet ist, das ist, wenn TestDriven.Net Abstürze

Hier ist der Stack-Trace für die Ausnahme:

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

Das gleiche Verhalten wird auch MsBuild auf unserem CI-Server zum Absturz bringen.

Was ist wirklich seltsam ist, dass in der Theorie in Finalisierung geworfen Ausnahmen () sollen gemäß der MSDN-Dokumentation geschluckt werden:

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

Finalisierung oder eine Überschreibung von Finalisierung gibt eine Ausnahme aus, die Laufzeit die Ausnahme ignoriert, beendet, dass Finalisierung Methode und die Finalisierung weiterhin Prozess.

Thoughts anyone?

War es hilfreich?

Lösung

Habe nie ganz auf den Grund dieser Frage, aber ich habe meine eigene LazyInitializer Umsetzung am Ende der Umsetzung durch die Schaffung einer eher rudimentären Arbeit um, wo ich für die Finalize-Methode auf invoke überprüfen, wie unten dargestellt:

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

Andere Tipps

Ich hatte das gleiche Problem, wenn ein I 2.1.2 Version von NHibernate migriert. Ich habe geändert Schloss für Linfu Proxy und dann alles funktionierte gut für mich. Hoffe, das hilft.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top