2010-09-17 34 views
0

我有MappingNHibernateException錯誤消息:NHibernate的裝載錯誤消息

{ 「無法編譯映射文檔:Infrastructure.DataAccess.Mappings.Post.hbm.xml」}

Could not find the dialect in the configuration 

在部分

Configuration configuration = new Configuration() 
       .AddAssembly("Infrastructure"); 
       _sessionFactory = configuration.BuildSessionFactory(); 

有什麼不對?


的hibernate.cfg.xml

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
    <session-factory>  
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> 
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver </property> 
    <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> 
    <property name="connection.connection_string">Server=localhost\SQLServer2005;database=NHibernate101;Integrated Security=True;</property> 
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> 
    <mapping assembly="Infrastructure"></mapping> 
    </session-factory> 
</hibernate-configuration> 

回答

0

試試這個。在app.config文件:

<configuration> 
    <configSections> 
    <section 
     name="hibernate-configuration" 
     type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" 
     /> 
    </configSections> 

    <!-- Replace with your values --> 
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
    <session-factory> 
     <property name="dialect">NHibernate.Dialect.SQLiteDialect</property> 
     <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> 
     <property name="connection.connection_string">Data Source=data.db3;Version=3</property> 
     <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver, NHibernate</property> 
     <property name="show_sql">true</property> 
     <property name="adonet.batch_size">0</property> 
     <property name="default_batch_fetch_size">0</property> 

     <mapping assembly="Infrastructure" /> 
    </session-factory> 
    </hibernate-configuration> 

</configuration> 

並在代碼:

var cfg = new Configuration().Configure(); 
var factory = cfg.BuildSessionFactory(); 
+0

我使用一個hibernate.cfg.xml文件,並在文件中我有......看在編輯的部分..我需要做點別的嗎? – learning 2010-09-20 05:56:24