views:

26

answers:

3

I've got a class library doing all my NHibernate stuff. It also handles all the mapping using Fluent NHibernate - no mapping files to deploy.

This class library is consumed by a number of apps, including a Windows Service running on my computer. Although it works fine in all my web apps, the Windows Service gets this when it tries to use NHibernate:

An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() at Kctc.NHibernate.KctcSessionFactory.get_SessionFactory() in C:\Kctc\Trunk\Kctc.NHibernate\KctcSessionFactory.cs:line 28 ...more stack trace...

I have checked for an InnerException and there doesn't appear to be one. I have no idea what the PotentialReasons collection is, and Google doesn't seem to be forthcoming either.

This is my dev machine, so when I'm working on my web apps they run locally (i.e. using the web server in Visual Studio). The fact that the Windows Service and my dev web apps are running on this same machine suggest it's not to do with trust settings or what have you.

Can anyone suggest what I should try? This is one of those ones where I'm so stumped I can't even think of how to get more information about the problem.

A: 

Just a wild guess. NHibernate picks up the hibernate.cfg.xml file from the execution directory. Did you configure the execution directory of the service that it can find this file?

Stefan Steinegger
I'm afraid I don't understand the question. There's no configuration file as I'm using FluentNHibernate. How do you configure the 'execution directory'?
David
A: 

I bet the name of the connection string is missing from the app.config. For me that message is almost exclusively a missing connection string.

Are you targeting the same database or could it be some sort of schema mismatch between databases?

Could it be authentication issues on the service like you use windows authentication where it can't be used (or the sql authentication that doesn't work)?

It's hard to tell when there is no code, just an exception!

EDIT Are you ever using HttpContext, HostingEnvironment or anything else specific to "web"?

mhenrixon
Sadly it's there. I know the basic ADO.NET stuff works as I still have pre-NHibernate data access code running in the service. But thanks for asking!
David
Added some more questions. You are not giving us a lot of information David :)
mhenrixon
Sorry, I'm not sure what to provide as I'm quite stuck. It's the same database as the live system. The class library does not demand any authentication. I haven't provided the configuration code because it's working for web apps, therefore surely it must be okay? Please let me konw what you would like me to post.
David
A: 

I've found out what the problem is. The Service did not deploy with the required NHibernate.ByteCode.LinFu.dll.

I appear to have an ongoing problem with the Visual Studio compiler not always copying indirect dependencies (i.e. dlls required by class libraries required by the app) into the output folder during the build. I should have thought of this sooner really.

Thanks for racking your brains on my behalf guys.

David
qstarin
Thank God! I AM NOT ALONE!
David