NHibernate.InstantiationException failed to load test type: <Foo>

we have a MVC 3.0 project with a rather large domain. Database access domain through Fluent NHibernate 3.0.

The project has been in production for several months, without any problems.

Today we are developing a Windows service that accesses the same domain in order to perform some batch operation. NHibernate failed to initialize, given the following error

NHibernate.InstantiationException could not load test type: <Foo> Inner Exception: Object reference not set to an instance of an object. 

The website is still running smoothly.

According to information found on the Internet, this problem occurs when there are some properties that cause POCO to be initialized in ctor. In fact, there are a lot of them in the domain, but the question is, why does the MVC project not explode and win32 does with the same domain?

Stefano

+4
source share
1 answer

The NHibernate error message was completely misleading, as it was a value missing from the applicationConfig section of app.configm that had nothing to do with NHibernate or mapping.

This is for future reference if anyone finds a similar problem.

+1
source

All Articles