0

I can't seem to find any decent (and recent) NHibernator examples for VB.NET on Visual Basic 2010 Express. However I have been trying to piece together everything I can.

However I always seem to get this error.

A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Xml.dll
A first chance exception of type 'NHibernate.Cfg.HibernateConfigException' occurred in NHibernate.dll
A first chance exception of type 'NHibernate.Cfg.HibernateConfigException' occurred in NHibernate.dll
a: An exception occurred during configuration of persistence layer.

I have nhibernator.cfg.xml at the root of the project containing the following

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

  <!-- For simplicity, the NHibernate configuration is stored in this file.
  It must be named hibernate.cfg.xml and marked in Visual Studio to be copied
  to the output folder.  -->

  <session-factory>

    <!-- By default NHibernate is aggressive in closing connections between
    SQL statments.  This unfortunately causes a problem when reading ID
    numbers assigned by Access (e.g. in AutoNumber fields).  See comments
    in the Test 1 section of Program.cs. -->

    <property name="hibernate.connection.release_mode">on_close</property>

    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
    <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>

    <!-- The Sample.mdb file is located in the folder containing the
    solution file.  This is three folders upward.  Relative paths
    are supported in Jet connection strings.  -->

    <property name="connection.connection_string">Provider=Microsoft.ACE.OLEDB.12.0;Data Source=database.accdb</property>
  </session-factory>
</hibernate-configuration>

Any help and insight is appreciated.

2
  • i just removed hibernate.connection.release_mode property as it was invalid according to the xsd sheets. still same error. Commented Apr 25, 2012 at 20:46
  • What is inside your app.config or web.config file? You can control where the hibernate configuration file is read from by using settings in the initial configuration file or place the entire configuration inside app.config. Commented Apr 25, 2012 at 22:59

2 Answers 2

1

I have nhibernator.cfg.xml at the root of the project containing the following

I think you want to name it hibernate.cfg.xml by default. Otherwise point the configuration to the new file.

Sign up to request clarification or add additional context in comments.

Comments

0

Is the file set to copy to the output folder? It's in its properties in Visual Studio. You should set it to copy always.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.