用nHibernate开发winform时出现总是出现The dialect was not set. Set the property hibernate.dialect.的异常。出现异常的地方在cfg.AddXmlFile的时候,请教高手们解答,谢谢!

解决方案 »

  1.   

    app.cofig文件中配置nhibernate有错误
      

  2.   

    下面是应用程序app.config设置,(连接Oracle),你可以参考一下。
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <configSections>
             <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
             <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
     </configSections>
     
     <nhibernate>
      <add 
       key="hibernate.connection.provider"          
       value="NHibernate.Connection.DriverConnectionProvider" 
      />
      <add 
       key="hibernate.dialect"                      
       value="NHibernate.Dialect.Oracle9Dialect" 
      />
      <add 
       key="hibernate.connection.driver_class"          
       value="NHibernate.Driver.OracleClientDriver" 
      />
      <add 
       key="hibernate.connection.connection_string" 
       value="Data Source=ORAZCY;user=EMERGENCY;password=emergency" 
      />
     </nhibernate>
     <log4net>
      <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
       <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] -%m%n" />
       </layout>
       <root>
        <level value="INFO" />
        <appender-ref ref="ConsoleAppender" />
       </root>
      </appender>
     </log4net>
      

  3.   

    我也出现这个错误,关注着
    我的配置文件是
    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.0" >
    <session-factory name="SeNet.Base.NHibernateAPI">
    <!-- properties -->
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=server;initial catalog=Test;user id=sa;password=123;Min Pool Size=2</property>
    <property name="show_sql">false</property>
    <property name="dialect">NHibernate.Dialect.MsSql2000Dialect/property>
    <property name="use_outer_join">true</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    <!-- mapping files -->
    <mapping file="People.hbm.xml"/> 
    <mapping file="Users.hbm.xml"/> 
    </session-factory>
    </hibernate-configuration>