2
我創建了一個示例項目來複制Castle Windsor和NHibernate Integration Facility中遇到的問題。Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration
我得到以下異常:
Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)'.
用下面的堆棧跟蹤:
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()
我有以下DLL版本:
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
此示例代碼我我用來加載容器並安裝Fluent NH配置:
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
這是使用的示例XML配置文件:
<?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>
因爲我已經張貼到溫莎城堡開發郵件列表和可能的解決了這一點。如果帳戶限制不到位,我會將此添加到有效答案中。 – Ross 2011-12-19 06:42:22
是的,這顯然是NHibernateIntegration沒有更新爲溫莎3的情況。 – 2011-12-19 13:52:45
是的,這是正確的。鏈接到我在開發職位。郵件列表在這裏:http://groups.google.com/group/castle-project-devel/browse_thread/thread/25c7902873cbad8b。我只是在等着看是否值得創建補丁。 – Ross 2011-12-19 22:36:53