在我们将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兼容?是否有可用的补丁可以下载以解决此问题?
我在stackoverflow上发现了类似的问题,并在项目跟踪器上记录了一个问题以解决问题。但这是2011年12月回归的Castle Windsor 3.0版,请看下面的链接。
Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration
修复程序是否在Castle.Core 3.3.0中没有出现?
或者我在这里遗漏了一些东西,任何帮助/建议都非常感谢。
由于
答案 0 :(得分:1)
NHibernateIntegration工具1.1.0不支持Castle Windsor 3.在最后一位维护人员搬迁后,Castle Project在过去的4年里一直没有维护该设施。记录在我们的旧问题跟踪器中的Issue FACILITIES-156在没有自己的用户提交拉取请求的用户之后死亡,因此从未应用过这些补丁。
在9月份登录的问题跟踪器上查看此问题,其中包含仍存在于Git存储库中的源代码的链接以及有关将其恢复生命的建议: https://github.com/castleproject/Windsor/issues/101