Escrevi o seguinte teste simples ao tentar aprender a Interface Fluente de Castle Windsor:
using NUnit.Framework;
using Castle.Windsor;
using System.Collections;
using Castle.MicroKernel.Registration;
namespace WindsorSample {
public class MyComponent : IMyComponent {
public MyComponent(int start_at) {
this.Value = start_at;
}
public int Value { get; private set; }
}
public interface IMyComponent {
int Value { get; }
}
[TestFixture]
public class ConcreteImplFixture {
[Test]
public void ResolvingConcreteImplShouldInitialiseValue() {
IWindsorContainer container = new WindsorContainer();
container.Register(Component.For<IMyComponent>().ImplementedBy<MyComponent>().Parameters(Parameter.ForKey("start_at").Eq("1")));
IMyComponent resolvedComp = container.Resolve<IMyComponent>();
Assert.AreEqual(resolvedComp.Value, 1);
}
}
}
Quando executo o teste através do TestDriven.NET, obtenho o seguinte erro:
System.TypeLoadException : Could not load type 'Castle.MicroKernel.Registration.IRegistration' from assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
at WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue()
Quando executo o teste através da NUnit GUI, obtenho:
WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue:
System.IO.FileNotFoundException : Could not load file or assembly 'Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
Se eu abrir a Assembléia que estou referenciando no Reflector, posso ver suas informações:
Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
e que ele definitivamente contém Castle.MicroKernel.Registration.IRegistration
O que poderia estar acontecendo?
Devo mencionar que os binários são retirados da versão mais recente do Castle, embora eu nunca tenha trabalhado com o nant, então não me incomodei em compilar novamente a partir do código-fonte e apenas peguei os arquivos no diretório bin. Devo também salientar que meu projeto é compilado sem nenhum problema.