2012-04-25 108 views
0

我似乎無法爲Visual Basic 2010 Express上的VB.NET找到任何體面的(和最近的)NHibernator示例。不過,我一直在拼盡全力拼湊一切。VB.NET NHibernate配置

但是我總是似乎得到這個錯誤。

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. 

nhibernator.cfg.xml在包含以下

<?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> 

任何幫助的項目的根和見解表示讚賞。

+0

我剛剛刪除了'hibernate.connection.release_mode'屬性,因爲它是根據'xsd'工作表無效的。還是一樣的錯誤。 – klj613 2012-04-25 20:46:56

+0

你的app.config或web.config文件裏面有什麼?您可以通過使用初始配置文件中的設置來控制讀取hibernate配置文件的位置,或者將整個配置放在app.config中。 – Min 2012-04-25 22:59:45

回答

1

我nhibernator.cfg.xml在包含以下

我想你需要將其命名默認hibernate.cfg.xml項目的根。否則,將配置指向新文件。

0

是否將文件設置爲複製到輸出文件夾?它在Visual Studio中的屬性中。您應該將其設置爲始終複製。

+0

它已經設置爲「始終複製」 – klj613 2012-04-25 20:45:56