开发者

TypeInitializationException When Getting an NHibernate Session

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 suc开发者_如何学Pythoncessfully 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜