Após a atualização para o Trunk Castelo e NHibernate 2.1.0.4000 Meu Integração testa TestDriven.Net acidente
-
11-09-2019 - |
Pergunta
Eu tenho um velho MonoRail / ActiveRecord Eu tenho feito alguns trabalhos também.
Recentemente, resolvi atualizar o aplicativo para Castelo Tronco & NHibernate 2.1.0.4000 GA e agora estou encontrando alguns problemas com testes de corrida:
Primeiro - Ao usar TestDriven.Net para executar os testes de integração que trabalham contra o banco de dados, ele está quebrando TestDriven.Net completamente, ou todos os testes de execução completo, então TestDriven.Net trava. Isso nunca aconteceu antes do upgrade.
Quando TestDriven.Net falhar, aqui está o que é escrito no registo de eventos:
Fault balde 1467169527, digite 1 Nome do Evento: APPCRASH Resposta: Não disponível Cab Id: 0
Problema assinatura: 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:
A segunda coisa - Exceções estão sendo registrados quando classes de proxy estão sendo Finalize () 'd, como abaixo -. Parece ser uma vez que este é registrado um par de vezes, que é quando TestDriven.Net acidentes
Aqui está o rastreamento de pilha da exceção:
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()
O mesmo comportamento também irá falhar MsBuild no nosso servidor de CI.
O que é realmente estranho é que na teoria exceções lançadas em Finalize () deverá ser engolida pela documentação do MSDN:
http: // MSDN. microsoft.com/en-us/library/system.object.finalize(VS.71).aspx
Se
Pensamentos alguém?
Solução
Nunca bastante chegou ao fundo desta questão, mas eu acabar implementando um trabalho bastante rudimentar em torno criando minha própria implementação LazyInitializer, onde eu verificar o método Finalize mediante invocação, como mostrado abaixo:
/// <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;
}
}
Outras dicas
Eu tive o mesmo problema quando a I migraram para 2.1.2 versão do NHibernate. Eu mudei Castelo para LinFu Proxy e então tudo funcionou bem para mim. Espero que isso ajude.