奇怪的城堡AddFacility运行时错误
我是 Castle 和 Castle.Windsor 的新手,所以这可能是一个菜鸟问题。
我创建了一个空的控制台 .NET 4.0 应用程序,并通过 NuGet 添加了下一个包:
- Castle Windsor 工厂支持设施 3.0 beta 1 (3.0.2001)
- Castle Windsor 3.0 beta 1 (3.0.2001)
- Castle Core 3.0 beta 1 (3.0.2001)
- Castle NHibernate 工具 (0.5.1.4000)
- Fluent NHibernate (1.3.0.717)
- NHibernate(3.2.0.4000)
- Iesi Collections(3.2.0.4000)
并编写了下一个代码:
static void Main(string[] args)
{
IWindsorContainer container = new WindsorContainer();
container.AddFacility<AutoTxFacility>();
//container.AddFacility<NHibernateFacility>();
}
但是我收到了一个错误:
“Castle.MicroKernel.Registration.RegistrationGroup`1[S]”上的 GenericArguments[0]、“TService”违反了类型参数“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.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.
我不明白我做错了什么。
I'am new to Castle and Castle.Windsor, so this is maybe a noob question.
I created an empty console .NET 4.0 application and added next packages through NuGet:
- Castle Windsor factory support facility 3.0 beta 1 (3.0.2001)
- Castle Windsor 3.0 beta 1 (3.0.2001)
- Castle Core 3.0 beta 1 (3.0.2001)
- Castle NHibernate facility (0.5.1.4000)
- Fluent NHibernate (1.3.0.717)
- NHibernate (3.2.0.4000)
- Iesi Collections (3.2.0.4000)
and wrote next code:
static void Main(string[] args)
{
IWindsorContainer container = new WindsorContainer();
container.AddFacility<AutoTxFacility>();
//container.AddFacility<NHibernateFacility>();
}
But I got an error:
GenericArguments[0], 'TService', on 'Castle.MicroKernel.Registration.RegistrationGroup`1[S]' violates the constraint of type parameter 'S'.
If rewrite code and uncomment second AddFacility line:
static void Main(string[] args)
{
IWindsorContainer container = new WindsorContainer();
//container.AddFacility<AutoTxFacility>();
container.AddFacility<NHibernateFacility>();
}
I got next error:
Could not load type 'Castle.Facilities.FactorySupport.FactorySupportFacility' from assembly 'Castle.Windsor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
I tried add container.AddFacility<Castle.Facilities.FactorySupport.FactorySupportFacility>();
line before first AddFacility but it not solve a problem.
In real application I got another error for same try and same libraries:
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)
with next 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.
I don't understand what I doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像您使用的 AutoTx 工具版本是针对旧版本的 Windsor 编译的。
我不确定该设施是否支持 Windsor 3,可能最好的做法是询问 城堡用户google组
This looks like the version of AutoTx facility you're using was compiled against older version of Windsor.
I'm not sure if the facility supports Windsor 3 yet, probably the best course of action is to ask at castle user googole group