我創建了一個項目,並使用NuGet安裝Nhibernate.Search。在安裝過程中,NuGet也爲我下載了Lucene.Net。FluentNhibernate,Nhibernate.Search和Lucene.Net版本
用的NuGet我有以下軟件包下載並安裝
- FluentNHibernate.dll:1.3.0733
- NHibernate.dll:3.3.1.4000
- NHibernate.Search.dll:2.0.2.4000
- Lucene.Net.dll:2.9.4.1
所有依賴項都由NuGet管理。但是,當我跑以下代碼
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Search.Event;
using NHibernate.Search.Store;
namespace Test {
public class NHibernateSearchSessionProvider {
private static ISessionFactory sessionFactory;
private static object syncRoot = new object();
public static ISessionFactory SessionFactory {
get {
lock (syncRoot) {
if (sessionFactory == null) {
sessionFactory = createSessionFactory();
}
return sessionFactory;
}
}
}
private static ISessionFactory createSessionFactory() {
var config = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("HomeDB"))
)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<UserAccountMap>())
.BuildConfiguration();
// Add NHibernate.Search listeners
config.SetListener(NHibernate.Event.ListenerType.PostUpdate, new FullTextIndexEventListener());
config.SetProperty("hibernate.search.default.indexBase", "~/LuceneIndex");
return config.BuildSessionFactory();
}
}
}
例外消息Could not load file or assembly 'Lucene.Net, Version=2.9.2.2, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
它看起來像這個版本NHibernate.Search仍使用的是Lucene.Net 2.9.2.2不是新的。我總是可以手動修復所有的依賴關係,但我更喜歡使用NuGet。
任何人都有經驗我應該怎麼做代碼工作?
感謝您的任何建議