The following exception is observed after we upgraded Castle Windsor from 2.5.2.0 to Castle Windsor 3.3 which is the latest version -
Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)
Stack Trace:
*[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)*
This is the sample code that configures 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");
}
The exception is thrown in container.AddFacility() call.
Below is the list of Castle Windsor and NHibernate assembly versions currently referenced in the projects:
- Castle.Core 3.3.0
- Castle.Windsor 3.3.0
- Castle.Facilities.NHibernateIntegration 1.1.0.39
- Castle.Services.Transaction 2.5.0.0
- NHibernate 3.1.0.4000
- FluentNHibernate 2.0.0.0
- Iesi.Collections 2.1.0.4000
What version of Castle Windsor is compatible with NHibernate Integration Facility? Is there a patch available that I can download to resolve this issue?
I found a similar question on stackoverflow and an issue was logged on the projects tracker for a resolution. But this was Castle Windsor version 3.0 way back in Dec 2011, see the link below.
Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration
Did the fix not make it in Castle.Core 3.3.0?
Or am I missing something here, any help / suggestion greatyl appreciated.
Thanks