1

I created a project, and used NuGet to install Nhibernate.Search. During the installation NuGet also downloads the Lucene.Net for me.

With NuGet I have following packages downloaded and installed

  • 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

All the dependencies are managed by NuGet. But when I ran following codes

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();
        }
    }
}

An exception message 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)

It looks like this version of NHibernate.Search is still using Lucene.Net 2.9.2.2 not the new one. I can always manually fix all the dependencies, but I prefer to use NuGet.

Anybody has experience how shall I do to make code work?

Thanks for any suggestion

hardywang
  • 4,864
  • 11
  • 65
  • 101

2 Answers2

0

This looks like a configuration error for the NHibernate.Search nuget package, it states that it supports Lucene.Net 2.9.2.2 and up. Try modifying your packages.config file to use the 2.9.2.2 version of Lucene (instead 2.9.4.1) and nuget will use the specified version during package restoration.

You will probably need to clean out your bin-folder to remove the "old" 2.9.4.1 assembly.

sisve
  • 19,501
  • 3
  • 53
  • 95
0

use Install-Package NHibernate.Search.MB I tried to fix it but it did not. Already Nhibernate.Search very old

seyfside
  • 117
  • 1
  • 7