0

私はいくつかの統合テストを実行してこれを使用しようとしています:

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

プラスこれ:

<?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>

Castle.Windsorバージョン3.1.0.0への参照がありますが、次のエラーが発生します。

ファイルまたはアセンブリ'Castle.Windsor、Version = 2.5.1.0、Culture = neutral、PublicKeyToken=407dd0808d44fbdc'またはその依存関係の1つを読み込めませんでした。見つかったアセンブリのマニフェスト定義がアセンブリ参照と一致しません。(HRESULTからの例外:0x80131040)

理由とこれを克服する方法がわかりませんか?ありがとう。

4

2 に答える 2

3

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

Add-BindingRedirect

Check the App.Config and you should now have binding redirects for the assemblies.

于 2013-01-11T01:18:28.380 に答える
1

NHibernate.ByteCode.Castle has a dependency on Castle as it uses DynamicProxy as its proxy factory. That issue was resolved with NHibernate 3.2 which has its own proxy factory and doesn't depend on Castle. If possible, upgrade NHibernate to at least 3.2 and remove the proxyfactory configuration from your nhibernate config file.

于 2013-01-10T16:00:48.220 に答える