版本更新后 Castle Windsor / NHibernate Integration Facility 中找不到方法错误

Method not found error in Castle Windsor / NHibernate Integration Facility after version updates

我们将 Castle Windsor 从 2.5.2.0 升级到最新版本 Castle Windsor 3.3 后出现以下异常 -

找不到方法:'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)

堆栈跟踪:

*[MissingMethodException: Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)'.]
   Castle.Facilities.NHibernateIntegration.Internal.NHSessionComponentInspector.ProcessModel(IKernel kernel, ComponentModel model) +0
   Castle.MicroKernel.ModelBuilder.<>c__DisplayClass6.<BuildModel>b__4(IContributeComponentModelConstruction c) +60
   System.Collections.Generic.List`1.ForEach(Action`1 action) +11702442
   Castle.MicroKernel.ModelBuilder.DefaultComponentModelBuilder.BuildModel(IComponentModelDescriptor[] customContributors) +223
   Castle.MicroKernel.Registration.ComponentRegistration`1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) +154
   Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) +179
   Castle.Facilities.NHibernateIntegration.NHibernateFacility.RegisterDefaultConfigurationBuilder() +398
   Castle.Facilities.NHibernateIntegration.NHibernateFacility.RegisterComponents() +221
   Castle.Facilities.NHibernateIntegration.NHibernateFacility.Init() +266
   Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel kernel, IConfiguration facilityConfig) +64
   Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility facility) +381
   Castle.MicroKernel.DefaultKernel.AddFacility(IFacility facility) +124
   Castle.MicroKernel.DefaultKernel.AddFacility(Action`1 onCreate) +165
   Castle.MicroKernel.DefaultKernel.AddFacility(String key, Action`1 onCreate) +85
   Castle.Windsor.WindsorContainer.AddFacility(String idInConfiguration, Action`1 configureFacility) +113
   IoC.IoCBootstrapper.CreateBaseContainer(String configPath) 
   IoC.IoCBootstrapper.InitializeForWeb(String configPath) 
   Web.Global_asax.Application_Start(Object sender, EventArgs e)*

这是配置 NHibernate 的示例代码:

var container = new WindsorContainer();
container.Kernel.ConfigurationStore.AddFacilityConfiguration("nHibernateFacility", Init());
container.AddFacility<NHibernateFacility>("nHibernateFacility", f => f.ConfigurationBuilder<FluentNHibernateConfigurationBuilder>());


public static MutableConfiguration Init(ProviderSchema schema, int factoryCount)
{
var facility = new MutableConfiguration("facility");
facility.Attributes.Add("id", "nhibernatefacility");
facility.Attributes.Add("isWeb", "true");
facility.Attributes.Add("type", "Castle.Facilities.NHibernateIntegration.NHibernateFacility, Castle.Facilities.NHibernateIntegration");
CreateFactory(facility, factoryCount, schema);
 return facility;
}

public static void CreateFactory(MutableConfiguration facility, int id, ProviderSchema schema)
{
var factory = facility.CreateChild("factory");
factory.Attributes.Add("id", string.Format("nhibernate.factory{0}", id));
factory.Attributes.Add("alias", schema.Name);
 var settings = factory.CreateChild("settings");

settings.CreateItem("connection.driver_class", schema.ProviderFactory)
.CreateItem("connection.connection_string", schema.ProviderDatabase)
.CreateItem("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle")
.CreateItem("dialect", "NHibernate.Dialect.MsSql2005Dialect")
.CreateItem("cache.provider_class", "NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache")
.CreateItem("cache.use_second_level_cache", "true")
.CreateItem("cache.default_expiration", "600")
.CreateItem("adonet.batch_size", "100")
.CreateItem("show_sql", "false");
}

在 container.AddFacility() 调用中抛出异常。

下面是项目中当前引用的 Castle Windsor 和 NHibernate 程序集版本列表:

哪个版本的 Castle Windsor 与 NHibernate Integration Facility 兼容?是否有可用的补丁可供我下载以解决此问题?

我在 Whosebug 上发现了一个类似的问题,并且在项目跟踪器上记录了一个问题以寻求解决方案。但这是 2011 年 12 月的 Castle Windsor 3.0 版本,请参阅下面的 link。

Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration

Castle.Core 3.3.0 中没有修复吗?

或者我在这里遗漏了什么,感谢任何帮助/建议。

谢谢

NHibernateIntegration 工具 1.1.0 不支持 Castle Windsor 3。在最后一个维护者离开后的过去 4 年里,Castle Project 一直没有维护该工具。 Issue FACILITIES-156,在 none 的创建自己的分支的用户提交了拉取请求后,登录我们的旧问题跟踪器就死了,所以没有那些补丁从未应用过。

在我们 9 月份记录的问题跟踪器上查看此问题,其中包含指向 Git 存储库中仍然存在的源代码的链接以及有关恢复它的建议: https://github.com/castleproject/Windsor/issues/101