问题
I have created a sample project to replicate an issue I'm having with Castle Windsor and the NHibernate Integration Facility.
I get the following exception:
Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)'.
With the following stack-trace:
at Castle.Facilities.NHibernateIntegration.Internal.NHSessionComponentInspector.ProcessModel(IKernel kernel, ComponentModel model)
at Castle.MicroKernel.ModelBuilder.DefaultComponentModelBuilder.<>c__DisplayClass6.<BuildModel>b__4(IContributeComponentModelConstruction c)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Castle.MicroKernel.ModelBuilder.DefaultComponentModelBuilder.BuildModel(IComponentModelDescriptor[] customContributors)
at Castle.MicroKernel.Registration.ComponentRegistration`1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel)
at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations)
at Castle.Facilities.NHibernateIntegration.NHibernateFacility.RegisterDefaultConfigurationBuilder()
at Castle.Facilities.NHibernateIntegration.NHibernateFacility.RegisterComponents()
at Castle.Facilities.NHibernateIntegration.NHibernateFacility.Init()
at Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel kernel, IConfiguration facilityConfig)
at Castle.MicroKernel.DefaultKernel.AddFacility(IFacility facility)
at Castle.Windsor.WindsorContainer.AddFacility(IFacility facility)
at Castle.Windsor.Installer.DefaultComponentInstaller.SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
at Castle.Windsor.Installer.DefaultComponentInstaller.SetUp(IWindsorContainer container, IConfigurationStore store)
at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope)
at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers)
at CW3_FluentNH_Integration_Tester.Main.Main() in D:\Documents and Settings\cannizrm\Desktop\Windsor3FluentTester\CW3_FluentNH_Integration_Tester\CW3_FluentNH_Integration_Tester\Main.vb:line 28
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I have the following DLL versions:
Castle.Core.dll - 3.0.0.2230
Castle.Windsor.dll - 3.0.0.2325
Castle.Facilities.NHibernateIntegration.dll - 1.1.039
FluentNHibernate.dll - 1.3.0.717
Iesi.Collections.dll - 3.2.0.4000
NHibernate.dll - 3.2.0.4000
This the sample code I am using to load the container and install the Fluent NH Configuration:
Imports Castle.Windsor
Module Main
#Region " Declarations "
Private objContainer As IWindsorContainer
#End Region
#Region " Properties "
Public ReadOnly Property Container As IWindsorContainer
Get
If objContainer Is Nothing Then
objContainer = New WindsorContainer()
End If
Return objContainer
End Get
End Property
#End Region
#Region " Functions "
Sub Main()
Container.Install(Castle.Windsor.Installer.Configuration.FromXmlFile ("Configs\hibernate.cfg.xml"))
End Sub
#End Region
End Module
This is the sample XML configuration file used:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<facilities>
<facility id="nhibernate" isWeb="false" type="Castle.Facilities.NHibernateIntegration.NHibernateFacility, Castle.Facilities.NHibernateIntegration">
<factory id="nhibernate.factory">
<settings>
<item key="show_sql">true</item>
<item key="connection.provider">NHibernate.Connection.DriverConnectionProvider</item>
<item key="connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
<item key="dialect">NHibernate.Dialect.MsSql2005Dialect</item>
<item key="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True</item>
</settings>
</factory>
</facility>
</facilities>
</configuration>
回答1:
I've registered this as an issue on the projects tracker and have included two patch files to resolve it.
http://issues.castleproject.org/issue/FACILITIES-156
来源:https://stackoverflow.com/questions/8557327/castle-windsor-3-fluent-nhibernate-castle-nhibernate-integration