【问题标题】:Strange Castle AddFacility runtime error奇怪的城堡 AddFacility 运行时错误
【发布时间】:2011-10-20 10:52:33
【问题描述】:

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

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

  1. 温莎城堡工厂支持设施 3.0 beta 1 (3.0.2001)
  2. 温莎城堡 3.0 beta 1 (3.0.2001)
  3. Castle Core 3.0 beta 1 (3.0.2001)
  4. 城堡 NHibernate 设施 (0.5.1.4000)
  5. 流畅的 NHibernate (1.3.0.717)
  6. NHibernate (3.2.0.4000)
  7. Iesi 集合 (3.2.0.4000)

然后写下一段代码:

    static void Main(string[] args)
    {
        IWindsorContainer container = new WindsorContainer();

        container.AddFacility<AutoTxFacility>();
        //container.AddFacility<NHibernateFacility>();
    }

但我得到了一个错误:

GenericArguments[0], 'TService', on '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&lt;Castle.Facilities.FactorySupport.FactorySupportFacility&gt;(); 行,但它不能解决问题。

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

无法加载文件或程序集“Castle.Windsor,版本=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.

我不明白我做错了什么。

【问题讨论】:

    标签: nhibernate castle-windsor castle castle-autotx


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-21
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多