配置mvc3和Nhibernate时出现以下错误。有人能指点我错过了什么吗?
方言没有被设置好。设置属性hibernate.dialect。描述:在执行当前web请求时发生了未处理的异常。请查看堆栈跟踪以获得有关错误的更多信息,以及它起源于代码的位置。
例外详细信息: NHibernate.HibernateException:没有设置方言。设置属性hibernate.dialect。
源错误:
第16行:{第17行: NHibernate.Cfg.Configuration配置=新NHibernate.Cfg.Configuration();第18行:NHibernate.Cfg.Configuration第19行: sessionFactory = configuration.BuildSessionFactory();第20行:}
我的web.config如下:
< name="cachingConfiguration"type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/>节< name="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,节log4net"/> <节name="hibernate-configuration"type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
<appSettings>
<add key="BusinessObjectAssemblies" value="Keeper.API"></add>
<add key="ConnectionString" value="Server=localhost\SQLSERVER2005;Database=KeeperDev;User=test;Pwd=test;"></add>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Server=localhost\SQLServer2005;Database=KeeperDev;User=test;Pwd=test;</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>发布于 2011-01-06 10:38:51
我犯了一个简单而愚蠢的错误。我还没有包括正确版本的NHibernate。
谢谢你的回复。
发布于 2011-01-05 13:40:26
从连接字符串中可以看出,您正在连接到2k5服务器。如果是,根据NHibernate文档,则应该将方言设置为NHibernate.Dialect.MsSql2005Dialect。
这是文档中的示例配置:
<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">Server=(local);Initial Catalog=dbname;User Id=user;Password=********</property>
</session-factory>如果将方言设置为NHibernate.Dialect.MsSql2005Dialect对您有用,您可以尝试。
https://stackoverflow.com/questions/4545098
复制相似问题