设置属性 hibernate.dialect 错误消息
我在配置 mvc3 和 Nhibernate 时遇到以下错误。谁能指导我我错过了什么。
未设置方言。设置属性 hibernate.dialect。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:NHibernate.HibernateException:未设置方言。设置属性 hibernate.dialect。
源错误:
第 16 行:{ 第 17 行:NHibernate.Cfg.Configuration 配置 = new NHibernate.Cfg.Configuration(); 第 18 行:configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly()); 第 19 行:sessionFactory = configuration.BuildSessionFactory(); 第 20 行:}
我的 web.config 如下:
<前><代码><节名称=“cachingConfiguration”类型=“Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching”/> <节名称=“log4net”类型=“log4net.Config.Log4NetConfigurationSectionHandler,log4net”/> <节名称=“hibernate-configuration”类型=“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>
I am having the following error when configuring mvc3 and Nhibernate. Can anyone guide me what I have missed please.
the dialect was not set. Set the property hibernate.dialect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: NHibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
Source Error:
Line 16: {
Line 17: NHibernate.Cfg.Configuration configuration = new NHibernate.Cfg.Configuration();
Line 18: configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly());
Line 19: sessionFactory = configuration.BuildSessionFactory();
Line 20: }
My web.config is as follows:
<configSections> <section name="cachingConfiguration"type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/> <section name="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> <section 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的连接字符串来看,您似乎正在连接到 2k5 服务器。如果是这样,根据 NHibernate 文档,方言应设置为
NHibernate .Dialect.MsSql2005Dialect
。这是文档中的示例配置:
您可以尝试将方言设置为
NHibernate.Dialect.MsSql2005Dialect
是否适合您。From your connection string, it appears that you are connecting to a 2k5 server. If so, according to the NHibernate docs, the dialect should be set to
NHibernate.Dialect.MsSql2005Dialect
.This is the sample configuration from the docs:
You could try if setting dialect to
NHibernate.Dialect.MsSql2005Dialect
works for you.我犯了一个简单而愚蠢的错误。我没有包含正确版本的 NHibernate。
感谢@Marjin 的回复。
I have done a simple and stupid mistake. I have not included the right version of NHibernate.
Thanks @Marjin for replying.