tags:

views:

93

answers:

1

I’ve run into what appears to be an NHibernate config problem. Basically, I ran up a simple proof of concept persistence integration test using NUnit, the test simply queries an Oracle database and successfully returns the last record received by the underlying table. However, when the assemblies are taken out of the NUnit test environment and deployed as they would be for an actual application build, my call for an NHibernate session results in a TypeInitializationException whilst executing the code line:

sessionFactory = New Configuration().Configure().BuildSessionFactory()

The application is a vb.net console app running against an Oracle 9.2 database, using a ‘coding framework’ published on the web by Bill McCafferty entitled 'NHibernate Best Practices with ASP.NET' (pre S#harp Architecture). I am running version 2.1.2.4000 of NHibernate.

Any assistance much appreciated.

Kind Regards

Paul J.

+1  A: 

You will get this exception if your nhibernate config file is broken, or if any of NHibernate's dependencies are missing (eg log4net).

The stacktrace will usually tell you what the problem is. Without seeing your config I can only guess, but some possible problems are:

  • incorrect namespace
  • config contains invalid elements or attributes
  • incorrect property names

These errors are easy to make if your config file is based on out of date documentation. For the current version, the XML configuration file is documented here.

Lachlan Roche
Thanks Lachlan appreciate your repsonse. Actually solved the problem, the Log4net.dll was not being generated in the output folder.
Paul Johnson