Strange Castle AddFacility运行时错误

时间:2011-10-19 19:58:39

标签: nhibernate castle-windsor castle castle-autotx

我是Castle和Castle.Windsor的新手,所以这可能是一个noob问题。

我创建了一个空的控制台.NET 4.0应用程序,并通过NuGet添加了下一个包:

  1. Castle Windsor工厂支援设施3.0 beta 1(3.0.2001)
  2. Castle Windsor 3.0 beta 1(3.0.2001)
  3. Castle Core 3.0 beta 1(3.0.2001)
  4. Castle NHibernate工厂(0.5.1.4000)
  5. Fluent NHibernate(1.3.0.717)
  6. NHibernate(3.2.0.4000)
  7. Iesi Collections(3.2.0.4000)
  8. 并编写了下一段代码:

        static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();
    
            container.AddFacility<AutoTxFacility>();
            //container.AddFacility<NHibernateFacility>();
        }
    

    但我收到了一个错误:

      

    GenericArguments [0],'TService','Castle.MicroKernel.Registration.RegistrationGroup`1 [S]'违反了类型参数'S'的约束。

    如果重写代码并取消注释第二个AddFacility行:

        static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();
    
            //container.AddFacility<AutoTxFacility>();
            container.AddFacility<NHibernateFacility>();
        }
    

    我收到了下一个错误:

      

    无法从程序集'Castle.Windsor,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 407dd0808d44fbdc'加载类型'Castle.Facilities.FactorySupport.FactorySupportFacility'。

    我尝试在第一个AddFacility之前添加container.AddFacility<Castle.Facilities.FactorySupport.FactorySupportFacility>();行,但它没有解决问题。

    在实际应用程序中,我为同一个尝试和相同的库得到了另一个错误:

      

    无法加载文件或程序集'Castle.Windsor,Version = 2.5.1.0,Culture = neutral,PublicKeyToken = 407dd0808d44fbdc'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)

    下一个FusionLog:

    === Pre-bind state information ===
    LOG: DisplayName = Castle.Windsor, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
    (Fully-specified)
    LOG: Appbase = file:///xxx.Test/bin/Debug
    LOG: Initial PrivatePath = NULL
    Calling assembly : Castle.Facilities.AutoTx, Version=3.0.202.2202, Culture=neutral, PublicKeyToken=407dd0808d44fbdc.
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: xxx.Test\bin\Debug\xxx.Test.dll.config
    LOG: Using host configuration file: 
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: Castle.Windsor, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
    LOG: Attempting download of new URL file:///xxx.Test/bin/Debug/Castle.Windsor.DLL.
    WRN: Comparing the assembly name resulted in the mismatch: Major Version
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
    

    我不明白我做错了什么。

1 个答案:

答案 0 :(得分:1)

这看起来像您使用的AutoTx工具版本是针对旧版Windsor编译的。

我不确定该设施是否支持Windsor 3,可能最好的做法是在castle user googole group询问