我在项目中使用app.config来配置nhibernate时测试正常
其中内容为:<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=1AC425E4D0B74F1;Initial Catalog=GuestBook;User ID=sa;Password=1</property>
      <mapping assembly="NhibernateSample.Model"/>
    </session-factory>
  </hibernate-configuration>
</configuration>
但是我看见很多直接使用的是"hibernate.cfg.xml"文件而不是app.config
于是我把app.config文件修改成hibernate.cfg.xml,并且也已经把该文件的输出选项设置为了“始终复制”<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Data Source=1AC425E4D0B74F1;Initial Catalog=GuestBook;User ID=sa;Password=1</property>
    <mapping assembly="NhibernateSample.Model"/>
  </session-factory>
</hibernate-configuration>
结果测试的时候一直显示的是:
NhibernateSample.Test.LeaveMessageDALTest.InsertTest:
NHibernate.MappingException : Could not compile the mapping document: NhibernateSample.Model.HbmMaps.Users.hbm.xml
  ----> System.InvalidOperationException : Could not find the dialect in the configuration不知是何故,请大家帮忙。