bernate异常及处理方法

  第一次实践nh,吧配置中遇到的问题记录一下,手写配置不容易啊,还好有schame.我当时真想暴走了,md整整花了我5个小时才把程序跑起来。

 

先说下我的环境

vs2008 + sqllite

 

1. mapping 文件 

   设置  生成操作-》嵌入的资源    

   异常内容 :

NHibernate.MappingException: An association from the table Orders refers to an unmapped class: NHibernate.Domain.Entities.Customer

2. hibernate.cfg.xml  

   设置  生成操作-》嵌入的资源     输出目录-》始终复制

 

3.sqllite 配置

请确认System.Data.SQLite.DLL的版本。不同的版本配置不同

官方提供的xml配置如下:

<property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>

我的配置如下:

<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>

如果运行时报错,请使用我的方法。

异常内容:

NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLiteDriver.

 

4.dll引用

所有和nhibernate.dll相关的dll都必须放在同一目录下。否则会出现无法找到相应的dll文件。

posted on 2012-05-02 14:27  HOT SUMMER  阅读(267)  评论(0编辑  收藏  举报

导航