I am trying to run some integration test and use this:
public class ServiceLocatorInitializer
{
public static void Init()
{
IWindsorContainer container = new WindsorContainer();
container.Register(
Component
.For(typeof(IEntityDuplicateChecker))
.ImplementedBy(typeof(EntityDuplicateChecker))
.Named("entityDuplicateChecker"));
container.Register(
Component.For(typeof(ISessionFactoryKeyProvider))
.ImplementedBy(typeof(DefaultSessionFactoryKeyProvider))
.Named("sessionFactoryKeyProvider"));
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
}
}
plus this:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">Data Source=:memory:;Version=3;New=True;</property>
<property name="connection.release_mode">on_close</property>
<property name="show_sql">true</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
I have a reference to Castle.Windsor version 3.1.0.0 but get this error:
Could not load file or assembly ‘Castle.Windsor, Version=2.5.1.0,
Culture=neutral, PublicKeyToken=407dd0808d44fbdc’ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
Not sure what the reason is and how to overcome this? Thanks.
WindsorServiceLocator is build against an older version of Castle and has not been updated.
You need to add a BindingRedirect in the App.Config of your test project, you should be able to add them by opening the Nuget Package Manager Console in visual studio, select the test project and run
Check the App.Config and you should now have binding redirects for the assemblies.